public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13403] New: postfix ++ messes up the equation
@ 2003-12-15 17:29 gcc at lantiainen dot com
  2003-12-15 17:46 ` [Bug c++/13403] " falk at debian dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: gcc at lantiainen dot com @ 2003-12-15 17:29 UTC (permalink / raw)
  To: gcc-bugs

Create and compile a simple program:
#include <iostream>
int main(){
      int i=0;
      i = 6+ i++ + 2000;
      std::cout << i << std::endl;
      return 0;
}

when running, it results "1" even when it should result "2006". If I remove the 
postfix operation "i++" the result is correct("2006"). As long as I keep 
that "i++" inside the equation I can divide, multiply, substract or add what 
ever I like, and the result is allways "1". ( There is exeption: Dividing with 
zero, creates warning and the result program craches like it should do. )

example: If the equation is
i = (6+ i++ + 2000)/2;
then "i" is still the same 1.

If I replace the postfix "i++" with prefix "++i" then the equation is 
calculated correctly, but the meaning is different( as you know prefix and 
postfix adding have different behaviour)).

-- 
           Summary: postfix ++ messes up the equation
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at lantiainen dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-sun-SunOs 5.8
  GCC host triplet: sparc-sun-SunOs 5.8
GCC target triplet: sparc-sun-SunOs 5.8


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


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

* [Bug c++/13403] postfix ++ messes up the equation
  2003-12-15 17:29 [Bug c++/13403] New: postfix ++ messes up the equation gcc at lantiainen dot com
@ 2003-12-15 17:46 ` falk at debian 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: falk at debian dot org @ 2003-12-15 17:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2003-12-15 17:46 -------
You are modifying i twice without an intervening sequence point, which is
invalid. See the documentation on -Wsequence-point.


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


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


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

* [Bug c++/13403] postfix ++ messes up the equation
  2003-12-15 17:29 [Bug c++/13403] New: postfix ++ messes up the equation gcc at lantiainen dot com
  2003-12-15 17:46 ` [Bug c++/13403] " falk at debian 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=13403


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

* [Bug c++/13403] postfix ++ messes up the equation
  2003-12-15 17:29 [Bug c++/13403] New: postfix ++ messes up the equation gcc at lantiainen dot com
  2003-12-15 17:46 ` [Bug c++/13403] " falk at debian 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=13403


^ 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 --
2003-12-15 17:29 [Bug c++/13403] New: postfix ++ messes up the equation gcc at lantiainen dot com
2003-12-15 17:46 ` [Bug c++/13403] " falk at debian 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).