2011/2/7 Ry deen <rydeen...@yahoo.co.jp>:
> Hi all,
>
> The code that contains the code shown below is compiled
> with arm-eabi-gcc -O2.
>        if((aaa_struct *)NULL == aaa) {
>                printf("1\n");
>        }
>        else {
>                printf("2\n");
>        }
>
>        bbb = aaa->member1;

The output is correct because deferencing a NULL pointer is undefined.
 GCC assumes after deferencing a pointer, the pointer will not be a
NULL pointer.

Use -fno-delete-null-pointer-checks if you don't want the compiler to
use this assumption (that is allowed by the C standard).

-- Pinski

Reply via email to