c++cvisual-studio-2010compiler-warnings

vs2010 C4353 why isn't this an error


I ran into this today in an if and after looking into it found that all these are all valid statements that generate the C4353 . My only guess is that this is the old way of doing noop in C. Why is this not an error. When would you use this to do anything useful.

int main()
{
    nullptr();
    0();
    (1 == 2)();
    return 0;

}

Solution

  • Using constant 0 as a function expression is an extension that is specific to Microsoft. They implemented this specifically because they saw a reason for it, which explains why it's wouldn't make sense to treat it as an error. But since it's non-standard, the compiler emits a warning.

    You are correct that it is an alternative to using __noop().