https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116619
Bug ID: 116619 Summary: Invalid null pointer constant accepted in the initializer of a pointer Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: luigighiron at gmail dot com Target Milestone: --- The following code is incorrectly accepted by GCC: int main(){ void*p=int(0); } This code is invalid because int(0) is not a null pointer constant. Clang and MSVC (with /permissive-) reject this program for this reason. Also, GCC rejects this as a null pointer constant in some other contexts, for example: #include<iostream> void foo(void*){ std::cout<<"1\n"; } void foo(...){ std::cout<<"2\n"; } int main(){ foo(0); foo(int(0)); } GCC prints "1 2" here (correctly) since int(0) isn't treated as a null pointer constant. Though not all other contexts handle this correctly, for example static_cast<void*>(int(0)) is also incorrect accepted.