While the below compiles (g++ compiler) it throws a runtime error "terminated in an unusual way." How can I allow passing NULL?
Code:void doSmth(std::string str) { //This causes the error only if NULL was actually passed if ( &str == NULL ) printf( "null" ); } int main(...) { //This one works fine doSmth( "string" ); //This cause it to crash doSmth( NULL ); //This will also cause a crash std::string tmp(NULL); doSmth( tmp ); }