This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/13522] New: Erroneous handling of negated negative integer literals


The following code 
 
const unsigned i1 = - (-2147483648); 
const unsigned i2 = - (- 2147483648); 
 
compiles erroneous on a Debian gnu-linux-i386 (GCC versions 2.95.4 and 3.3.2). 
The compiler gives the warning that the values are unsigned only (which they 
are, they are definitively positive). When You look at the produced assembler 
code: 
 
        .file   "bug.c" 
.globl i1 
        .section        .rodata 
        .align 4 
        .type   i1, @object 
        .size   i1, 4 
i1: 
        .long   -2147483648 
.globl i2 
        .align 4 
        .type   i2, @object 
        .size   i2, 4 
i2: 
        .long   -2147483648 
        .section        .note.GNU-stack,"",@progbits 
        .ident  "GCC: (GNU) 3.3.2 (Debian)" 
 
You will note, that one of the minus signes simply vanished without effect. 
 
Best Regards 
Sven

-- 
           Summary: Erroneous handling of negated negative integer literals
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sven at clio dot in-berlin dot de
                CC: gcc-bugs at gcc dot gnu dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]