The following example compiles (VS2010 C++ compiler issues a warning C4353 though) and expression (*) evaluates to 0
:
#include <iostream>
#include <string>
int main()
{
0(1, "test"); // (*) - any number and type of arguments allowed
int n = 0(1, "test"); // 0
std::string str(0(1, "test")); // Debug assertion fails - 0 pointer passed
}
Is using 0
as a function name allowed/regulated by C++ standard or its resolution is compiler-specific? I was looking in the N3242 draft but could not find anything related to this. Microsoft compiler obviously resolves such construct (or one with __noop
) as an integer with value 0
.
warning C4353:
warning C4353: nonstandard extension used: constant 0 as function expression. Use __noop function intrinsic instead