[Bug c/37642] GCC applies signed strict-overflow rules to unsigned short type
pinskia at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Sep 24 17:46:00 GMT 2008
------- Comment #2 from pinskia at gmail dot com 2008-09-24 17:44 -------
Subject: Re: New: GCC applies signed strict-overflow rules to unsigned short
type
When doing addition unsigned short is promoted to an signed int. So
this is not a bug. That is unsigned short + 1 is a signed int since 1
is a signed int.
Sent from my iPhone
On Sep 24, 2008, at 10:29 AM, "alexandre dot nunes at gmail dot com"
<gcc-bugzilla@gcc.gnu.org
> wrote:
> I'll submit a testcase that apparently demonstrates that gcc is
> trying to apply
> signed strict overflow rules to an unsigned short type, at least on
> 32 bit
> machines when short is 16 bit.
>
> Here is the output:
> arm-elf-gcc -O2 -W -Wall -Wstrict-overflow=5 -c testcase.c
> testcase.c: In function âÂÂincr_counterâÂÂ:
> testcase.c:13: warning: assuming signed overflow does not occur when
> assuming
> that (X + c) < X is always false
>
> this is from gcc 4.3.1; my native build also has the same semantics,
> and I've
> tested with 4.2.4 also.
>
> The thing is that the type is unsigned (even if it is smaller than
> the target
> machine register), so that it can overflow and it can be detected
> (costly
> perhaps, but can).
>
>
> --
> Summary: GCC applies signed strict-overflow rules to
> unsigned
> short type
> Product: gcc
> Version: 4.2.4
> Status: UNCONFIRMED
> Severity: normal
> Priority: P3
> Component: c
> AssignedTo: unassigned at gcc dot gnu dot org
> ReportedBy: alexandre dot nunes at gmail dot com
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37642
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37642
More information about the Gcc-bugs
mailing list