[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: i = i++
the C standard says, in section
> 6.5,
>
> [#2] 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 accessed only to determine the
> value to be
> stored.60)
> *
ok! so does this mean that even a statement like
++i++ ;
is not defined. i thought that prefix has precedence
over postfix . so the statement evaluates to (++i)++.
since prefix returns an lvalue, it can be operated on
by postfix and so it sould give a difinite answer. am
i wrong ?
btw. i asked this question coz we were asked a
question like i = i+++++i+i++ ; in some apptitude test
and the people who evaluated claimed that the answer
'undefined' was wrong! beat that!
>
> And the footnote 60 is:
>
> 60)This paragraph renders undefined
> statement expressions
> such as
> i = ++i + 1;
> a[i++] = i;
> while allowing
> i = i + 1;
> a[i] = i;
>
> The standard is quite clear here that the original
> expression (i = i++;)
> is undefined.
>
> Binand
>
>
> ---------------------------------------------
> Find out more about this and other Linux India
> mailing lists at http://lists.linux-india.org/
__________________________________________________
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!
http://photos.yahoo.com/