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: Ian Lance Taylor <iant at google dot com>
- To: Iain Buclaw <ibuclaw at gdcproject dot org>
- Cc: Andreas Schwab <schwab at linux-m68k dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 23 Nov 2013 07:54:39 -0800
- 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> <m2zjovo0om dot fsf at linux-m68k dot org> <CABOHX+cpB3OZwsbePZjmm4Bb-yQ3fqh413ySpdB3+T0PD6RT8A at mail dot gmail dot com>
On Sat, Nov 23, 2013 at 4:38 AM, Iain Buclaw <ibuclaw@gdcproject.org> wrote:
>
> OK, I've checked that document, and there's also a comment with it.
> Apparently someone spotted this before.
>
> @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.
>
>
> So where does this leave languages that say that pointer to integer
> conversions are clearly defined?
The language frontend needs to do the right thing. In this case it
looks like the right thing is to convert the integer to the language
equivalent of uintptr_t before converting it to a pointer type.
Other than possibly from the frontend function convert, a language
frontend really has no business calling convert_to_integer at all.
The function implements C semantics. And the whole business of the
middle-end calling the frontend function convert is broken anyhow.
Ian