Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any situations where code would have a sequence point in c++11 but not c++03?

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?

like image 738
shuttle87 Avatar asked Feb 15 '12 12:02

shuttle87


People also ask

What is a sequence point in C?

A sequence point defines any point in a computer program's execution at which it is guaranteed that all side effects of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed.


1 Answers

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.

like image 184
Prasoon Saurav Avatar answered Sep 22 '22 08:09

Prasoon Saurav