public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19798] New: Prefix ++ doing wrong in an addition
@ 2005-02-07  6:26 ceniza666 at yahoo dot com
  2005-02-07  6:45 ` [Bug c/19798] " pcarlini at suse dot de
  0 siblings, 1 reply; 2+ messages in thread
From: ceniza666 at yahoo dot com @ 2005-02-07  6:26 UTC (permalink / raw)
  To: gcc-bugs

A program as simple as:
  int b = 10;
  int a;
  a = (++b) + (++b) + (++b);
  printf("%d", a);

shows the wrong answer.

It should be 36, it shows 37. Optimisations on or off throw the same result.

Source of the problem: Generated code.

Pseudo C/asm code:
++b;
++b;
%eax = b;
%edx = b;
%edx += %eax;
++b;
%edx += b
a = %edx

So, when it should be doing "a = 11 + 12 + 13;" it's doing "a = 12 + 12 + 13;".

-- 
           Summary: Prefix ++ doing wrong in an addition
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ceniza666 at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c/19798] Prefix ++ doing wrong in an addition
  2005-02-07  6:26 [Bug c/19798] New: Prefix ++ doing wrong in an addition ceniza666 at yahoo dot com
@ 2005-02-07  6:45 ` pcarlini at suse dot de
  0 siblings, 0 replies; 2+ messages in thread
From: pcarlini at suse dot de @ 2005-02-07  6:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2005-02-07 00:19 -------


*** This bug has been marked as a duplicate of 11751 ***

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


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


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

end of thread, other threads:[~2005-02-07  0:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-07  6:26 [Bug c/19798] New: Prefix ++ doing wrong in an addition ceniza666 at yahoo dot com
2005-02-07  6:45 ` [Bug c/19798] " pcarlini at suse dot de

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).