2 ms·
including C and C++, it's specified that the RHS is evaluated first. I did not check C++ but for C, according to ISO/IEC 9899:1999 section 6.5.16 paragraph 4 o
by userbinator 8y ago
including C and C++, it's specified that the RHS is evaluated first.
I did not check C++ but for C, according to ISO/IEC 9899:1999 section 6.5.16 paragraph 4 on the semantics of the assignment operator: "The order of evaluation of the operands is unspecified."
- tlb 8y agoGosh, you're right. Clang warns, at least: t-order.c:10:8: warning: unsequenced modification and access to 'x' [-Wunsequenced] foo[x++] = x;
- ngcc_hk 8y agoLanguage that is complicated in syntax also ended up with discussion like that. A couple of day ago you have the VisiCalc guy talked about he need to do a stack machine against the expectation here. Think of lisp But then lisp require parentheses Think of j but the strange right hand side then fork/train. It is hard for this simple thing. Even = and =: get Python dictator for life resigned. Just hard