From: Tom Tromey <tromey@adacore.com>
To: Luis Machado <luis.machado@linaro.org>
Cc: gdb-patches@sourceware.org, Tom Tromey <tromey@adacore.com>
Subject: Re: [PATCH] Don't inherit range-type signed-ness from underlying type
Date: Tue, 20 Oct 2020 07:55:30 -0600 [thread overview]
Message-ID: <87blgxknn1.fsf@tromey.com> (raw)
In-Reply-To: <a0fe5654-05ae-091d-8818-7e4de29331b7@linaro.org> (Luis Machado's message of "Mon, 19 Oct 2020 18:28:24 -0300")
>> This passed testing -- but unfortunately, additional testing at
>> AdaCore showed that this change was incorrect. GNAT, at least, can
>> emit an unsigned range type whose underlying type is signed.
Luis> Is this correct compiler behavior though? It sounds inconsistent. If
Luis> the compiler wants an unsigned type for a range, intuitively it should
Luis> use an unsigned base type, no?
Good question. I'll update the comment in the patch with the answer.
The test case shows the problem -- it has a type whose range is 0..65535
(inclusive), but whose underlying type is a signed integer. Also, the
program requests that values of this range type be stored in 16 bits.
This is fine because the range of values fits.
However, if the type inherits the sign from the underlying type, if we
fetch such a value, it will be incorrectly sign-extended.
I do think it's the case, though, that if the underlying type is
unsigned then the range type must be. We could consider adding that.
Tom
next prev parent reply other threads:[~2020-10-20 13:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-19 19:33 Tom Tromey
2020-10-19 21:28 ` Luis Machado via Gdb-patches
2020-10-20 13:55 ` Tom Tromey [this message]
2020-10-26 18:53 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87blgxknn1.fsf@tromey.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=luis.machado@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox