G
Gianni Mariani
Note that F() takes the address of a 0 size vector. Should the code
below be considered "bad" ? STLPort complains about it but gcc and
VC++7.1 eat it fine.
#include <string>
#include <iostream>
#include <vector>
struct foo
{
foo( char * ix, size_t is )
: x( ix ), s( is )
{
}
char * x;
size_t s;
};
std::vector<char> v;
foo F()
{
return foo( & v[0], v.size() );
}
int main()
{
std::cout << F().s << std::endl;
}
below be considered "bad" ? STLPort complains about it but gcc and
VC++7.1 eat it fine.
#include <string>
#include <iostream>
#include <vector>
struct foo
{
foo( char * ix, size_t is )
: x( ix ), s( is )
{
}
char * x;
size_t s;
};
std::vector<char> v;
foo F()
{
return foo( & v[0], v.size() );
}
int main()
{
std::cout << F().s << std::endl;
}