GCC 3.4 optimisation of if (&ptr == NULL)

Andrew Pinski pinskia@physics.uc.edu
Thu Dec 4 01:51:00 GMT 2003


On Dec 3, 2003, at 17:30, John Neil wrote:

> I recently spent time upgrading my embedded application form gcc 3.2 
> to the
> current cvs version of gcc 3.4.  Whilst doing this I found that gcc 
> 3.4 was
> removing the "if (&ptr == NULL) as shown in the following test case
>
> extern void* g_ptr;


What you want is to mark the variable as weak otherwise GCC assumes the 
address is not
0.

Thanks,
Andrew Pinski



More information about the Gcc mailing list