This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Null pointer dereference and side effects
- From: Archie Cobbs <archie at dellroad dot org>
- To: law at redhat dot com
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 19 Jul 2004 10:40:45 -0500 (CDT)
- Subject: Re: Null pointer dereference and side effects
Jeffrey A Law wrote:
> > I have a question about GCC optimizations and null pointers.
> > Consider this program:
> >
> > #include <stdlib.h>
> >
> > int
> > main(int ac, char **av)
> > {
> > int *r1;
> > int *r2;
> >
> > r1 = ∾
> > *r1 = 0;
> > r2 = (void *)0; /* or (void *)1, etc. */
> > if (*r1 != *r2)
> > return 1;
> > return 1;
> > }
> >
> > When run & compiled with gcc -O2 (gcc 3.2.2) it does not segfault.
>
> -fno-delete-null-pointer-checks.
Doesn't seem to help in this case (at least not with gcc 3.2.2).
Thanks,
-Archie
__________________________________________________________________________
Archie Cobbs * CTO, Awarix * http://www.awarix.com