A simple non-portable expression tha
VLD/VMB
gwyn at BRL.ARPA
Sat Apr 19 17:24:03 AEST 1986
No, the compiler is not free to associate right-to-left in an
expression
long + int + int.
Addition associates left-to-right, and the integral widening
conventions apply, so the middle term must be converted to long
and added to the leftmost term before the rightmost term is
added. The compiler is allowed to reorder this only if it
guarantees the same answer as would be obtained by following
the rules. On machines where integer overflow is ignored,
the opportunity arises more frequently than on those where
it traps. However, in this example, information could be
lost by overflow if the compiler treated the expression as
long + (int + int)
so it is not allowed to do that.
More information about the Comp.lang.c
mailing list