This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/11751] wrong evaluation order of an expression


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11751

--- Comment #89 from Oleg <oraytman1 at comcast dot net> ---
Is this produces correct output?

#include <cstring>
#include <cstdio>

int main()
{
  int i = 100;
  i = i++ + ++i;
  printf("i=%d\n", i);

  i = 100;
  i = ++i + i++;
  printf("i=%d\n", i);

  i = 100;
  i = i + i++;
  printf("i=%d\n", i);
  return 0;
}

output:

i=202
i=203

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]