Created on 2007-07-26.00:00:00 last changed 196 months ago
[Voted into the WP at the September, 2008 meeting.]
Proposed resolution (March, 2008):
Change 6.9.1 [intro.execution] paragraph 16 as follows:
...If a side effect on a scalar object is unsequenced relative to either
a differentanother side effect on the same scalar object or a value computation using the value of the same scalar object, the behavior is undefined. [Example:void f(int, int); void g(int i, int* v) { i = v[i++]; // the behavior is undefined i = 7, i++, i++; // i becomes 9 i = ++i + 1; // the behavior is undefined i = i + 1; // the value of i is incremented f(i = -1, i = -1); // the behavior is undefined }—end example] When calling...
Is the behavior undefined in the following example?
void f() { int n = 0; n = --n; }
6.9.1 [intro.execution] paragraph 16 says,
If a side effect on a scalar object is unsequenced relative to either a different side effect on the same scalar object or a value computation using the value of the same scalar object, the behavior is undefined.
It's not clear to me whether the two side-effects in n=--n are “different.” As far as I can tell, it seems that both side-effects involve the assignment of -1 to n, which in a sense makes them non-“different.” But I don't know if that's the intent. Would it be better to say “another” instead of “a different?”
On a related note, can we include this example to illustrate?
void f( int, int ); void g( int a ) { f( a = -1, a = -1 ); } // Undefined?
History | |||
---|---|---|---|
Date | User | Action | Args |
2008-10-05 00:00:00 | admin | set | messages: + msg1803 |
2008-10-05 00:00:00 | admin | set | status: ready -> cd1 |
2008-06-29 00:00:00 | admin | set | status: review -> ready |
2008-05-18 00:00:00 | admin | set | messages: + msg1636 |
2008-05-18 00:00:00 | admin | set | status: drafting -> review |
2007-10-09 00:00:00 | admin | set | status: open -> drafting |
2007-07-26 00:00:00 | admin | create |