struct f { int i; }; void link_error (); void g(struct f *i) { i->i = 1; if (&i->i == 0) link_error (); } int main() { struct f n; g(&n); }
There should be no references to link_error. The following is optimized: void link_error (); void g(int *i) { *i = 1; if (i == 0) link_error (); } int main() { int n; g(&n); } -- Summary: Missed removal of null pointer check Product: gcc Version: 4.1.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pinskia at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21294