mardi 29 décembre 2015

Conversion from int to nullptr

Consider following code:

void f( void * );

int main()
{
    f( 0 );               // compiles fine
    f( 1 - 1 );           // compiles fine
    constexpr int i = 0;
    f( i );               // fails to compile, cannot convert int to void *
    f( i - 0 );           // compiles fine
}

why f( i ) fails to compile, though i should be evaluated as compile time constant with value 0?

PS checked with g++ v 5.1.0

Aucun commentaire:

Enregistrer un commentaire