https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61543
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid Status|UNCONFIRMED |NEW Last reconfirmed| |2017-05-12 CC| |msebor at gcc dot gnu.org Ever confirmed|0 |1 Known to fail| |4.8.3, 4.9.3, 5.3.0, 6.2.0, | |7.1.0 --- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> --- Confirmed. GCC seems to treat rvalues of integer types with zero value as the literal 0. $ cat t.C && gcc -S -Wall t.C const int i = 0; void *p0 = static_cast<void *>(i); void *p1 = static_cast<void *>(static_cast<int>(i)); // accepted enum { e = 0 }; void *q = static_cast<void *>(static_cast<int>(e)); // accepted y.C:3:33: error: invalid static_cast from type ‘const int’ to type ‘void*’ void *p0 = static_cast<void *>(i); ^