gcc3 vs 176.gcc
Joseph S. Myers
jsm28@cam.ac.uk
Wed Jan 9 14:11:00 GMT 2002
On Wed, 9 Jan 2002, Joe Buck wrote:
> Nope. You asked for a proof that the aliasing rules are being violated.
> Examination of the two insns reveals that the same location is being
> accessed twice, it says nothing about whether this is a legal alias or
> a violation of ISO C.
That should be done by somehow carrying down the information about what
is/is not assumed to alias on the based of the type-based rules (here, the
information that those accesses to that location had been assumed not to
alias).
> 3) the real type is an array of char. Again, if accesses take place
> through both the casted and uncasted pointers, we have an ISO C violation,
> so this is a bug just waiting to happen.
One can equally argue that whenever a programmer uses a cast, they are
telling the compiler that they know what's going on (here, hopefully
accessing parts of an array in one type and parts in another type), are
taking responsibility for it making sense and following the standard, and
don't want to be told otherwise. The point of a pointer cast would be to
avoid diagnostics about incompatible pointer types - not then to get the
compiler to say it knows better.
Also, even if a warning is given, that doesn't mean that the optimisation
should be disabled - the warning should suffice to get the programmer to
fix their code.
--
Joseph S. Myers
jsm28@cam.ac.uk
More information about the Gcc
mailing list