User account creation filtered due to spam.

Bug 21246 - Compiler fails when using and incrementing a variable i: f(i,++i) equivalent to f(i+1,i+1); ++i
Summary: Compiler fails when using and incrementing a variable i: f(i,++i) equivalent...
Status: RESOLVED DUPLICATE of bug 11751
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P1 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2005-04-27 07:36 UTC by Jesús Andrés
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesús Andrés 2005-04-27 07:36:56 UTC
The next code, should show int the screen "a:2 b:3"; but shows "a:3 b:3".
I have tested it into several versions from 3.3 to 4.0. Always the same result.

void foo(int a,int b)
{
  std::cout<<"a:"<<a<<" b:"<<b<<std::endl;
}

int main()
{
  int n=2;
  foo(n,++n);
}
Comment 1 Giovanni Bajo 2005-04-27 11:40:51 UTC
This is not a bug, the order of evaluation is unspecified.
Read about this here:
http://gcc.gnu.org/bugs.html
section "Increment/decrement operator (++/--) not working as expected"

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