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

Reply via email to