[Bug target/21479] optimizer removes incorrectly variable comparision in if clause
schlie at comcast dot net
gcc-bugzilla@gcc.gnu.org
Tue May 10 08:32:00 GMT 2005
------- Additional Comments From schlie at comcast dot net 2005-05-10 08:31 -------
(In reply to comment #5)
> see comment #1 ...
>
> you already derefenced the pointer in ppv (in the line
> unsigned long lv = *lvp;
> )
>
> so the compiler assumes that anohter NULL ptr check is not needed.
- yes, however as the loigical extention of:
"a null reference is undefined" => "may trap" => "will trap"
is simply wrong, and is not justifyable; such an optimization
is target specific, as it depends on "will trap" target semantics.
(not to mention that even if it is trapped for a particular target,
that the target won't simply return some value, so pointer null
comparsions can't be reliably optimized away unless the compiler
can also enforce dereferenced null pointer trap semantics for that
particualr target, which GCC does not appear to do.)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21479
More information about the Gcc-bugs
mailing list