This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] pointer to integer conversion.
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: Iain Buclaw <ibuclaw at gdcproject dot org>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 23 Nov 2013 11:46:33 +0100
- Subject: Re: [PATCH] pointer to integer conversion.
- Authentication-results: sourceware.org; auth=none
- References: <CABOHX+cxn+h+Jr8Z+JE0XBdbOQ6hBtHTUX=0j=LFYyHoq199vg at mail dot gmail dot com>
Iain Buclaw <ibuclaw@gdcproject.org> writes:
> Currently, GCC is converting the expression to a signed integer
> instead of an unsigned one. Does a test for the testsuite need to be
> written for this?
The C standard makes this implementation-defined, and GCC defines it
like this (*Note (gcc) Arrays and pointers implementation::):
A cast from pointer to integer discards most-significant bits if
the pointer representation is larger than the integer type,
sign-extends(1) if the pointer representation is smaller than the
integer type, otherwise the bits are unchanged.
---------- Footnotes ----------
(1) Future versions of GCC may zero-extend, or use a target-defined
`ptr_extend' pattern. Do not rely on sign extension.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."