Due to a bug, I just found out that this code compiles fine on with Visual Studio 17 and probably on other compilers as well. Now I'm curious why?
#include <iostream> #include <string> std::string foo(){ return nullptr; } int main(){ auto s = foo(); std::cout << s << std::endl; } I could imagine it is because the std::basic_string c'tor could be invoked with a char* and while returning an implicit conversion from ptr to std::string occurs (with NULL as argument and then goes poof). Am I on the right way?
nullptras the parameter for a pointerstring (nullptr_t) = deletector, just so this error is caught at compile time. I don't think legitimate programs would break due to that.