[Bug c/37642] GCC applies signed strict-overflow rules to unsigned short type

2008-09-24 Thread alexandre dot nunes at gmail dot com


--- Comment #1 from alexandre dot nunes at gmail dot com  2008-09-24 17:29 
---
Created an attachment (id=16403)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16403action=view)
This is the first testcase.

compile with gcc -O2 -W -Wall -Wstrict-overflow=5


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37642



[Bug c/37642] GCC applies signed strict-overflow rules to unsigned short type

2008-09-24 Thread pinskia at gmail dot com


--- 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
[EMAIL PROTECTED] 
  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



[Bug c/37642] GCC applies signed strict-overflow rules to unsigned short type

2008-09-24 Thread alexandre dot nunes at gmail dot com


--- Comment #3 from alexandre dot nunes at gmail dot com  2008-09-24 20:42 
---
(In reply to comment #2)
 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
 

Hah, living and learning. That actually makes sense, thanks, I'll refine the
test.


-- 

alexandre dot nunes at gmail dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37642