This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/13522] New: Erroneous handling of negated negative integer literals
- From: "sven at clio dot in-berlin dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Dec 2003 15:34:18 -0000
- Subject: [Bug c/13522] New: Erroneous handling of negated negative integer literals
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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