https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99235
Bug ID: 99235 Summary: Null pointer check incorrectly deleted for static pointer Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: sebastianquilter at gmail dot com Target Milestone: --- int main() { static char* ptr = (char*)1; --ptr; if(ptr){ return 1; } return 0; } Compiled with -O0, it returns 0 Compiled with -O1, it returns 1 Compiled with -O1 -fno-delete-null-pointer-checks, it returns 0