public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15012] New: Unexpected behaviour on i--
@ 2004-04-19 15:08 mdeluigi at student dot ethz dot ch
  2004-04-19 15:15 ` [Bug c++/15012] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mdeluigi at student dot ethz dot ch @ 2004-04-19 15:08 UTC (permalink / raw)
  To: gcc-bugs

Try that code:
---8<---
int j = 2;
int i = 2;
i = i-- + ++j;
cout << i;
--->8---
The suprising result is that i == 1.
I tried this on pc (intel), powerpc and sparc.

The result is because the compiler does something like:
---8<---
tmp1 = i--;
tmp2 = ++j;
i = i + tmp2;
i = tmp1;
--->8---
(check the asm-code for more details).

That's not what the programer expects.

-- 
           Summary: Unexpected behaviour on i--
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mdeluigi at student dot ethz dot ch
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/15012] Unexpected behaviour on i--
  2004-04-19 15:08 [Bug c++/15012] New: Unexpected behaviour on i-- mdeluigi at student dot ethz dot ch
@ 2004-04-19 15:15 ` pinskia at gcc dot gnu dot org
  2004-08-05 14:57 ` bangerth at dealii dot org
  2004-08-05 15:01 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-19 15:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-19 14:56 -------
Invalid as you are modifing i twice without a sequence point inbetween.
i = i-- + ++j;
^    ^

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


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


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

* [Bug c++/15012] Unexpected behaviour on i--
  2004-04-19 15:08 [Bug c++/15012] New: Unexpected behaviour on i-- mdeluigi at student dot ethz dot ch
  2004-04-19 15:15 ` [Bug c++/15012] " pinskia at gcc dot gnu dot org
@ 2004-08-05 14:57 ` bangerth at dealii dot org
  2004-08-05 15:01 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2004-08-05 14:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-08-05 14:57 -------
Reopen these bugs... 

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


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


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

* [Bug c++/15012] Unexpected behaviour on i--
  2004-04-19 15:08 [Bug c++/15012] New: Unexpected behaviour on i-- mdeluigi at student dot ethz dot ch
  2004-04-19 15:15 ` [Bug c++/15012] " pinskia at gcc dot gnu dot org
  2004-08-05 14:57 ` bangerth at dealii dot org
@ 2004-08-05 15:01 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2004-08-05 15:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-08-05 15:01 -------
...mark as duplicate of PR 11751. 

*** 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=15012


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

end of thread, other threads:[~2004-08-05 15:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-19 15:08 [Bug c++/15012] New: Unexpected behaviour on i-- mdeluigi at student dot ethz dot ch
2004-04-19 15:15 ` [Bug c++/15012] " pinskia at gcc dot gnu dot org
2004-08-05 14:57 ` bangerth at dealii dot org
2004-08-05 15:01 ` bangerth at dealii 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).