A there any g++ options which can detect improper initialization of std::string with NULL const char*?
I was in the process of turning some int fields into std::string ones, i.e:
struct Foo
{
int id;
Foo() : id(0) {}
};
...turned into:
struct Foo
{
std::string id;
Foo() : id(0) {} //oooops!
};
I completely overlooked bad 'id' initialization with 0 and g++ gave me no warnings at all. This error was detected in the run time(std::string constructor threw an exception) but I'd really like to detect such stuff in the compile time. Is there any way?
std::string::string(int);. That would be a better match, and thus cause a compile-time error.inttostring. Modifystd::basic_stringin g++'s standard headers, check that the new code compiles, then change it back fast, before anyone notices.std::string::string(std::nullptr_t)constructor that will cause this to be ill-formed, with diagnostic.