9

Now that the new c++11 standard has made changes in how sequence points are described I'm trying to find out exactly what has been changed between c++03 and c++11.

In particular, are there any situations where code that looks the same would have a sequence point in c++11 but not c++03?

shuttle87
  • 15,466
  • 11
  • 77
  • 106

2 Answers2

9

There are no sequence points in C++11, rather there are sequenced before and sequenced after relations.

Here are some trivial examples wherein behavior differ between C++03 and C++11

int x = 10;
++++x; // well defined in C++11

int x = 10;
x = ++x +1; //well defined in C++11

Why? Have a look at this answer and related threads.

Community
  • 1
  • 1
Prasoon Saurav
  • 91,295
  • 49
  • 239
  • 345
4

I think the best known example is the pre-increment operator.

int i = 0;
++ ++ ++ i;

In C++03, this would be UB, and in C++11, each assignment is ordered before the next evaluation.

Searching the Standard for differences is tough because they got rid of the "sequence point" terminology in favor of "ordered before" and the like, and rewrote much of the rules from scratch.

Potatoswatter
  • 134,909
  • 25
  • 265
  • 421
  • `Searching the Standard for differences is tough because they got rid of the "sequence point" terminology ` this is the exact reason I posted this question. – shuttle87 Feb 15 '12 at 12:49
  • @shuttle87 Yeah, sorry about that, but at least I came up with one example ;v) – Potatoswatter Feb 15 '12 at 12:50