public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/13522] New: Erroneous handling of negated negative integer literals
@ 2003-12-30 16:50 sven at clio dot in-berlin dot de
  2003-12-30 17:17 ` [Bug c/13522] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: sven at clio dot in-berlin dot de @ 2003-12-30 16:50 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/13522] Erroneous handling of negated negative integer literals
  2003-12-30 16:50 [Bug c/13522] New: Erroneous handling of negated negative integer literals sven at clio dot in-berlin dot de
@ 2003-12-30 17:17 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-30 17:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-30 16:50 -------
INT_MAX+1 is always unsigned and cannot have a sign so the first minus does not apply.
To form INT_MIN do -INT_MAX - 1.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-12-30 16:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-30 16:50 [Bug c/13522] New: Erroneous handling of negated negative integer literals sven at clio dot in-berlin dot de
2003-12-30 17:17 ` [Bug c/13522] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).