On Saturday, 9 November 2013 at 17:53:41 UTC, Johannes Pfau wrote:
Am Sat, 9 Nov 2013 17:01:43 +0000
schrieb Iain Buclaw <ibuc...@ubuntu.com>:

On 9 November 2013 12:19, Johannes Pfau <nos...@example.com> wrote:
> The fix is simple:
> in gcc/convert.c(convert_to_integer):
>
> /* Convert to an unsigned integer of the correct width > first, and
> from there widen/truncate to the required type.  Some targets
> support the coexistence of multiple valid pointer sizes, so > fetch
> the one we need from the type.  */
>       expr = fold_build1 (CONVERT_EXPR,
>                           lang_hooks.types.type_for_size
>                             (TYPE_PRECISION (intype), 0),
>                           expr);
>
>
That code does seem to contradict what the comment is saying. I'll
raise it in #gcc and send a patch  (unless you want to do it).



It indeed seems like it's only a small oversight. It'd be
great if you could report it.

Apparently it's working as per C semantics, which means the behavior is undefined. I've mentioned that it makes no sense that documentation/code don't match comments. But all I've heard back is that you shouldn't use convert_to_integer in the front end (except maybe through convert() - which I am 90% certain is the case with us), and to implement our own semantics if we say that pointer to integer conversion is clearly defined in D.

Regards
Iain.

Reply via email to