Compiler generates unexpected code when the ++ command is used in function parameters. The compiler seems to reverse the order of the parameters (see code it is much easier to view, than to describe) I don't know if this is C++ legal to do this, but it is the reverse of everything I am used to and a bit irritating. I will download the latest version of g++ and test it (manana). I don't know if it even belongs to g++ yet. Thanks m NOT present in g++ gcc version 2.8.1. Release: gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) Environment: Linux substitute 2.2.14-5.0 #1 Tue Mar 7 21:07:39 EST 2000 i686 unknown How-To-Repeat: // UNDER 2.91.66 with BUG g++ test1.cc -o test1 test1 This is matts compiler test program 1 6 5 4 3 2 1 // incorrect This is test_fun 6 5 4 3 2 1 // incorrect This is test_fun 6 5 4 3 2 1 // incorrect This is test_fun 1 2 3 4 5 6 // correct This is test_fun 1 2 3 4 5 6 // correct // BY COMPARISON // UNDER 2.8.1 with NO BUG test1 This is matts compiler test program 1 1 2 3 4 5 6 This is test_fun 1 2 3 4 5 6 This is test_fun 1 2 3 4 5 6 This is test_fun 1 2 3 4 5 6 This is test_fun 1 2 3 4 5 6 // correct every time!
Fix: Can code around it and maybe fixed in newer g++, can't find it in the bug list.
State-Changed-From-To: open->closed State-Changed-Why: you've invoked undefined effects. There are no sequence points between evaluating function arguments.
From: nathan@gcc.gnu.org To: gcc-gnats@gcc.gnu.org, nobody@gcc.gnu.org, super.aorta@ntlworld.com Cc: Subject: Re: c++/816 Date: 17 Nov 2000 16:51:36 -0000 Synopsis: function parameters incorrect order when using ++ as a parameter State-Changed-From-To: open->closed State-Changed-By: nathan State-Changed-When: Fri Nov 17 08:51:36 2000 State-Changed-Why: you've invoked undefined effects. There are no sequence points between evaluating function arguments. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=816&database=gcc
Reopening to mark as a duplicate of...
...PR 11751. *** This bug has been marked as a duplicate of 11751 ***