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: dewar at gnat dot com
- Subject: Re: Bug in loop optimize (invalid postinc to preinc transformation)
- From: Jamie Lokier <egcs at tantalophile dot demon dot co dot uk>
- Date: Wed, 3 Jan 2001 09:51:47 +0100
- Cc: schwab at suse dot de, 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
- References: <20001231163045.5B3B534D81@nile.gnat.com>
dewar@gnat.com wrote:
> 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.
The point (no pun intended) is that the problematic example code
includes a constant-valued pointer (unsigned char *) 0xffffffff. Such a
pointer does not refer to any object unless your semantic model is a
flat space, in which all objects are sub-objects of a single "all of
memory" object.
> As C compilers get more clever, they are likely to be less permissive
> to abuses of the semantics :-)
Indeed. As with strict type aliasing, as the compilers get more clever,
the programmers need clear definitions of which semantics they may rely
on from a particular compiler. Many, many programs have a small part
that depends on traditional behaviour that's not defined in the ISO
standard.
-- Jamie