below c code will get "false" at -O0, -O1, -O3,
and get "true" at -O2, -Os.

#include <stdio.h>

typedef struct {
    int aa;
    int bb;
} test;

//test t1;

void foo (test **pp) 
{ 
    if (((*pp)->bb != 0) && (*pp)) 
        printf ("true\n");
    else 
        printf ("false\n");

    printf ("finished.\n");
}

int main (void)
{
        test *p;
        p = NULL;
        foo (&p);
        return 0; 
}


-- 
           Summary: [4.2 Regression] there seems to be a gcc optimization
                    problem.
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: liqin at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-elf


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32079

Reply via email to