[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Re: WinAVR 20050214 (gcc 3.4.3) and optimizer bug.
From: |
Jeff Epler |
Subject: |
Re: [avr-gcc-list] Re: WinAVR 20050214 (gcc 3.4.3) and optimizer bug. |
Date: |
Mon, 9 May 2005 10:47:20 -0500 |
User-agent: |
Mutt/1.4.1i |
On Mon, May 09, 2005 at 08:21:12AM -0700, Larry Barello wrote:
> I didn't understand everything that was said, but it seemed clear to me that
> having the construct
>
> char *foo;
>
> if (foo && (*foo !=0))
>
> randomly break seemed pretty harsh.
As I recall, your original code was more like
1 char *foo;
2 char bar = *foo;
3 if(foo && (*foo != 0)) { ... }
Dereferencing a NULL pointer causes undefined behavior. GCC assumes
unixish semantics, where the dereference would cause the program to
exit. In that sense, the result of the test of foo on line 3 is
performed on line 2 when foo is dereferenced.
Since AVR doesn't have unixish semantics for "NULL"-pointer
dereferences, maybe -fno-delete-null-pointer-checks should be the
default no matter the -O level.
Maybe the bit pattern for NULL should not be all zeros, but that's an
even bigger change to contemplate.
Jeff
pgpAe6KcLRiHZ.pgp
Description: PGP signature
- [avr-gcc-list] Re: WinAVR 20050214 (gcc 3.4.3) and optimizer bug., Joerg Wunsch, 2005/05/08
- [avr-gcc-list] Re: WinAVR 20050214 (gcc 3.4.3) and optimizer bug., Vesa Jääskeläinen, 2005/05/08
- Re: [avr-gcc-list] Re: WinAVR 20050214 (gcc 3.4.3) and optimizer bug., E. Weddington, 2005/05/08
- Re: [avr-gcc-list] Re: WinAVR 20050214 (gcc 3.4.3) and optimizer bug., Russell Shaw, 2005/05/09
- Re: [avr-gcc-list] Re: WinAVR 20050214 (gcc 3.4.3) and optimizer bug., E. Weddington, 2005/05/09
- RE: [avr-gcc-list] Re: WinAVR 20050214 (gcc 3.4.3) and optimizer bug., Larry Barello, 2005/05/09
- Re: [avr-gcc-list] Re: WinAVR 20050214 (gcc 3.4.3) and optimizer bug., E. Weddington, 2005/05/09
- Re: [avr-gcc-list] Re: WinAVR 20050214 (gcc 3.4.3) and optimizer bug.,
Jeff Epler <=
- Re: [avr-gcc-list] Re: WinAVR 20050214 (gcc 3.4.3) and optimizer bug., Vesa Jääskeläinen, 2005/05/09
- Re: [avr-gcc-list] Re: WinAVR 20050214 (gcc 3.4.3) and optimizer bug., Russell Shaw, 2005/05/09