J
j
In a footnote in the c99 standard the following is labeled as
undefined:
a[i++] = i;
And in the second clause of section 6.5 the following is stated:
"Between the previous and next sequence point an object shall have its
stored value modified at most once by the evaluation of an expression.
Furthermore, the prior value shall be read only to determine the value
to be stored. 70)"
So my question is, how do they derive undefined behaviour from "a[i++]
= i;" ?
With, a[i++] = i; this is one expression and there is only one
sequence point here, ';'.
'i' has its value modified only once and that is in the subscript
operator to designate which object the value of 'i', on the right side
of the assignment operator, will be stored at.
But, I am guessing I am missing something here. So if anyone could
enlighten me it would be much appreciated
Also, what is the difference between unspecified behaviour and
undefined behaviour? The standard attempts to make a distinction
between the two in Annex J but my dictionary gives the same definition
for "unspecified" and "undefined" so I fail to see how they can be
used to describe certain things as though they were different.
undefined:
a[i++] = i;
And in the second clause of section 6.5 the following is stated:
"Between the previous and next sequence point an object shall have its
stored value modified at most once by the evaluation of an expression.
Furthermore, the prior value shall be read only to determine the value
to be stored. 70)"
So my question is, how do they derive undefined behaviour from "a[i++]
= i;" ?
With, a[i++] = i; this is one expression and there is only one
sequence point here, ';'.
'i' has its value modified only once and that is in the subscript
operator to designate which object the value of 'i', on the right side
of the assignment operator, will be stored at.
But, I am guessing I am missing something here. So if anyone could
enlighten me it would be much appreciated
Also, what is the difference between unspecified behaviour and
undefined behaviour? The standard attempts to make a distinction
between the two in Annex J but my dictionary gives the same definition
for "unspecified" and "undefined" so I fail to see how they can be
used to describe certain things as though they were different.