This is the mail archive of the
mailing list for the GCC project.
Re: Possible issue with integer promotion for << and >> in gcc.4.5.3
- From: Arthur Schwarz <aschwarz1309 at att dot net>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 18 Dec 2012 17:44:00 -0800 (PST)
- Subject: Re: Possible issue with integer promotion for << and >> in gcc.4.5.3
- References: <1355870392.38278.YahooMailRC@web181306.mail.ne1.yahoo.com> <CAKOQZ8xzLJFBTC6=UoUKxGtVES80y8mwRgaamFatw1G_Lc0m5g@mail.gmail.com>
I don't see how I misread the output. The output shows that char <op> long
promotes to LONG except for the shift operations. char <op> ulong promotes to
ULONG except shift operations promote to INT.uchar <op> long promotes to LONG (I
would have expected ULONG) except for shift operations which promote to INT.
uchar <op> ulong promotes to ULONG except for shifts and long <op> ULONG
promotes to ULONG except for shifts.
Can you explain how I have misread the output and/or what the standard defines
as the correct promotion?
I am at this stage very confused as to what is correct and what is not. If the
output defines the correct output (which it might) then it seems inconsistent as
well as inconsiderate.
----- Original Message ----
From: Ian Lance Taylor <email@example.com>
To: Arthur Schwarz <firstname.lastname@example.org>
Sent: Tue, December 18, 2012 4:56:11 PM
Subject: Re: Possible issue with integer promotion for << and >> in gcc.4.5.3
On Tue, Dec 18, 2012 at 2:39 PM, Arthur Schwarz <email@example.com> wrote:
> I have run some tests to determine the gcc 4.5.3 integer promotion policies.
This message is not appropriate for the mailing list firstname.lastname@example.org,
which is for the development of GCC itself. It would be appropriate
on the mailing list email@example.com. Please take any followups
to firstname.lastname@example.org. Thanks.
The integer promotion policies are the ones specified in the language standard.
> tests show that for 'char' input, "char << long" and "char >> long" promote to
> INT while other operations using a long promote to" long", and that "char <<
> ulong" and "char >> ulong" promote to INT while other operations using ulong
> promote to "ulong". In similar fashion, "long << long" and "long >> long"
> promote to INT while other promotions are to long, and that "long << ulong"
> "long >> ulong" promote to long while other operations promote to ulong. The
> code used and the output are included below.
The shift operators produce a value of the same type as the left
operand, subject to the usual integer promotions. You say in the
paragraph above that long << long promotes to INT, but that sounds
unlikely, and I don't see any support for that in the program output
that you showed.
You suggest that there is a bug somewhere, but I don't see one.