integer arithmetic vs alias analysis
Fergus Henderson
fjh@cs.mu.oz.au
Fri Aug 10 21:36:00 GMT 2001
On 10-Aug-2001, Richard Henderson <rth@redhat.com> wrote:
> + A cast from pointer to integer discards most-significant bits if the
> + pointer representation is larger than the integer type, sign-extends
> + if the pointer representation is smaller than the integer type, otherwise
> + the bits are unchanged.
> + @c ??? We've always claimed that pointers were unsigned entities.
> + @c Shouldn't we therefore be doing zero-extension? If so, the bug
> + @c is in convert_to_integer, where we call type_for_size and request
> + @c a signed integral type. On the other hand, it might be most useful
> + @c for the target if we extend according to POINTERS_EXTEND_UNSIGNED.
Most people will read the formatted documentation, not the texinfo source,
so they may read this and start relying on it (since it is now officially
documented).
I suggested adding a footnote or parenthesized remark
"Future versions of GCC may use zero-extension rather than sign-extension
when converting pointers to larger-sized integer types. Programmers
should not rely on such conversions using sign-extension."
Note that GCC issues an unconditional warning for such conversions,
unless the pointer is a constant (e.g. obtained via a cast from an
integer constant). So the compiler already discourages this.
But let's not encourage it in the manual.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: < http://www.cs.mu.oz.au/~fjh > | -- the last words of T. S. Garp.
More information about the Gcc-patches
mailing list