Are pointers to be supposed to be sign or zero extended to wider integers?

Martin Guy martinwguy@gmail.com
Fri Feb 12 13:40:00 GMT 2010


On 2/12/10, Richard Guenther <richard.guenther@gmail.com> wrote:
> On Fri, Feb 12, 2010 at 10:41 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>  > It seems pointers are sign extended to wider integers, is that intentional?

>  Your program prints zero-extends for ICC.
>
>  Probably the behavior is undefined and we get a warning anyway:

All C requires is that casting a opinter to an integer and back again
should be a no-op, so either behaviour should work, although there's a
more detailed explanation here with references to the language
standards:
http://gcc.gnu.org/onlinedocs/gcc/Arrays-and-pointers-implementation.html

To address your specific point, it says:
"extends according to the signedness of the integer type if the
pointer representation is larger than the integer type"

    M



More information about the Gcc mailing list