Bug 17018 - address increment of function parameters changes their order
Summary: address increment of function parameters changes their order
Status: RESOLVED DUPLICATE of bug 11751
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.3.1
: P2 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-13 14:36 UTC by Svetozar Markov
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 Svetozar Markov 2004-08-13 14:36:43 UTC
gcc -v reports:
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
Configured with: /netrel/src/gcc-3.3.1-2/configure --enable-languages=c,c++,f77,
java --enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls --wi
thout-included-gettext --enable-interpreter --enable-sjlj-exceptions --disable-v
ersion-specific-runtime-libs --enable-shared --build=i686-pc-linux --host=i686-p
c-cygwin --target=i686-pc-cygwin --prefix=/usr --exec-prefix=/usr --sysconfdir=/
etc --libdir=/usr/lib --includedir=/nonexistent/include --libexecdir=/usr/sbin
Thread model: posix
gcc version 3.3.1 (cygming special)

The program is:

#include <stdio.h>

void foo( char c1, char c2, char c3 ) {
  printf( "%c%c%c\n", c1, c2, c3 );
}

int main( int argc, char **argv ) {
  int i = 0;
  char a[] = "abc";
  char *pc = a;
  foo( a[i++], a[i++], a[i++] );
  foo( *pc++, *pc++, *pc++ );
  i = 0;
  pc = a;
  foo( a[i++], a[i++], a[i] );
  foo( *pc++, *pc++, *pc );
  return 0;
}

The output is:
cba
cba
baa
baa

When I would expect (and I got with gcc 2.95.2 under Solaris 9!):
abc
abc
abc
abc
Comment 1 Andrew Pinski 2004-08-13 14:41:10 UTC
Order of execution is undefined in this case.
Comment 2 Wolfgang Bangerth 2004-08-13 15:40:03 UTC
That's a duplicate of... 
Comment 3 Wolfgang Bangerth 2004-08-13 15:40:28 UTC
...PR 11751. 

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