This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Bug in loop optimize (invalid postinc to preinc transformation)
- To: egcs at tantalophile dot demon dot co dot uk, schwab at suse dot de
- Subject: Re: Bug in loop optimize (invalid postinc to preinc transformation)
- From: dewar at gnat dot com
- Date: Sun, 31 Dec 2000 11:30:45 -0500 (EST)
- Cc: aoliva at redhat dot com, denisc at overta dot ru, dkorn at pixelpower dot com,gcc at gcc dot gnu dot org, peter dot osterlund at mailbox dot swipnet dot se
<<Comparing pointers that don't point to the same (part of) object is
undefined.
>>
Indeed. The important thing to remember in C is that the semantic
model of a pointer is a pair (pointer-to-object, offset). Address
arithmetic just modifies the offset, comparison compares only the
offsets (and is undefined if the pointer-to-object values are
different).
Of course in practice the implementation is typically a single pointer
from a flat space, representing the sum of the two components, but the
proper semantic model needs to be kept in mind, and code that does not
respect this semantic model has undefined effects.
As C compilers get more clever, they are likely to be less permissive
to abuses of the semantics :-)