https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103830
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|rtl-optimization |ipa Last reconfirmed| |2021-12-26 Target Milestone|--- |12.0 Summary|volatile optimized away |[12 Regression] null | |pointer access optimized | |away by removing function | |call at -Og Status|UNCONFIRMED |NEW CC| |hubicka at gcc dot gnu.org, | |marxin at gcc dot gnu.org, | |pinskia at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- What was removed is not the null pointer itself but rather the function calls to both MyClass::call and intermediate. cddce: Eliminating unnecessary statements: Deleting : MyClass::call (_4); Eliminating unnecessary statements: Deleting : intermediate (D.2427); >From local-const-pure: local analysis of void MyClass::call()/1 NULL memory access; terminating BB checking previously known: void MyClass::call()/1 is not a malloc candidate, reason: No return value. Function is locally const. .... The question is do we want to do const-pure at -Og really. >it is IMHO invalid to optimize it away (at -Og): No, it is valid to remove as it is undefined behavior, the question comes do we want to do the removal at -Og; I suspect no.