#10 14.05.07 23:08
#11 14.05.07 23:10
#12 14.05.07 23:15
Re: [C] странный результат
efferson написал(а):
Посему стоит юзать только те компиляторы, которые соответствуют ANSI
смотрим стандарт:
5
4. Except where noted, the order of evaluation of operands of individual operators and subexpressions of individual expressions, and the order in which side effects take place, is unspecified.53) Between the previous and next sequence point a scalar 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. The requirements of this paragraph shall be met for each allowable ordering of the subexpressions of a full expression; otherwise the behavior is undefined. [Example:
i = v[i++]; // the behavior is unspecified
i = 7, i++, i++; // i becomes 9
i = ++i + 1; // the behavior is unspecified
i = i + 1; // the value of i is incremented
так что разрешение таких ситуаций отдано компиляторам, и как они поступят зависит только от разработчиков компилятора. А значит нельзя сказать, что компилятор не следует стандарту, все они следуют стандарту.
Offline
#13 14.05.07 23:40
Re: [C] странный результат
efferson написал(а):
СнегаН, неа - тоже было бы 14. Ячейка памяти то одна ;)
скомпилил на J IDEA... 13
причём, съедает только так: i=++i+ ++i; //с пробелом между плюсами
Исправлено kvazimodo (14.05.07 23:44)
Offline

