In the following program, the if() is only removed if one removes the line "r[1]=0;". (4.3.0 20061107; x86_64-unknown-linux-gnu-gcc)
#include <stdlib.h> void foo (void); int main() { int *restrict r; r = malloc(2*sizeof(int)); r[0] = 0; r[1] = 0; if(r[0]) foo(); return 0; } main () { int * restrict r; void * D.1998; <bb 2>: D.1998 = malloc (8); r = (int * restrict) D.1998; *r = 0; *(r + 4B) = 0; if (*r != 0) goto <L0>; else goto <L1>; <L0>:; foo (); <L1>:; return 0; } -- Summary: Missed optimization of restrict pointer assigned value Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29751