On Wed, Mar 6, 2013 at 8:29 AM, Jens Rottmann
<[email protected]> wrote:

> Per default, after any *ptr, GCC assumes a SEGFAULT would occur if ptr was 
> ==0, so if control flow does reach the following code ptr must be !=0. ==> 
> After any *ptr GCC will optimize away all ptr==0 or !=0 checks.  I know that 
> because I recently hunted a related bug for a week (U-Boot, ARM, different 
> project) until I looked at the actual assembly code.


And here I thought that no-delete-null-pointer-checks had been taken
out after all the problems it caused. Silly me. I wonder how many of
the gcc compiler writers understand C's original purpose :-) I was
quite shocked when I read of this "optimization" some years ago.

Yeah, we need to ensure -fno-delete-null-pointer-checks is set on any
compiler foolish enough to implement this sort of thing.

ron

-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to