To my astonishment, this compiles:
const char* c_str()
{
static const char nullchar = '\0';
return nullchar;
}
and it introduced a bug in my code. Thankfully, I caught it.
Is this intentional by C++, or a compiler bug? Is there a reason why the data type is actively ignored?
It worked in Visual C++ 2010 and GCC, but I don't understand why it should work, given the obvious data type mismatch. (The static isn't necessary, either.)