This is the mail archive of the
cgen@sourceware.org
mailing list for the CGEN project.
Re: [PATCH] Make large enum constants unsigned
- From: Stefan Kristiansson <stefan dot kristiansson at saunalahti dot fi>
- To: "Maciej W. Rozycki" <macro at codesourcery dot com>
- Cc: Stefan Kristiansson <stefan dot kristiansson at saunalahti dot fi>, cgen at sourceware dot org, Alan Modra <amodra at gmail dot com>, fche at sourceware dot org, Christian Svensson <blue at cmd dot nu>, Pierre Muller <pierre dot muller at ics-cnrs dot unistra dot fr>
- Date: Thu, 22 May 2014 09:52:50 +0300
- Subject: Re: [PATCH] Make large enum constants unsigned
- Authentication-results: sourceware.org; auth=none
- References: <20140522052921 dot GA30609 at chokladfabriken dot org> <alpine dot DEB dot 1 dot 10 dot 1405220702380 dot 512 at tp dot orcam dot me dot uk>
On Thu, May 22, 2014 at 9:21 AM, Maciej W. Rozycki
<macro@codesourcery.com> wrote:
> On Thu, 22 May 2014, Stefan Kristiansson wrote:
>
>> this fixes a bug noted in two threads on the binutils mailing list:
>> https://sourceware.org/ml/binutils/2014-05/msg00152.html
>> https://sourceware.org/ml/binutils/2014-05/msg00195.html
>>
>> Both threads describe the problem pretty well, but the gist of it
>> is that constants are generated that will be interpreted as signed.
>>
>> 2014-05-22 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
>>
>> * enum.scm (gen-enum-decl): Emit 'ULL' after constants larger than
>> #x80000000
>
> Well, `ULL' is non-standard for pre-C99 compilers and also not needed
> because an enum will never have a type that is wider than `int'. So for
> portability's sake I suggest that you use `U' or `u' as I proposed (I
> prefer lowercase `u' for decimal constants because I find it easier to
> spot among digits, however please feel free to take your pick).
>
Hmm, right.
I actually had a plain 'U' in my first version of the patch, but then
changed it to 'ULL' last minute with the thought of being future proof
against possible larger mask values.
But as you point out, that will have issues anyway, so I'll repost
with the original patch.
As for 'u' vs 'U', a 'U' is emitted in the .h file even if I put a 'u'
in the .scm.
If 'u' in the output is preferred, maybe someone can point out the
reason for this?
Stefan