Quantcast
Channel: User CPlus - Programming Language Design and Implementation Stack Exchange
Viewing all articles
Browse latest Browse all 65

What optimizations are possible with unsequenced operators?

$
0
0

In C, most binary operators do not specify which operand will be evaluated first:

int x(void) {    putchar('x');    return 10;}int y(void) {    putchar('y');    return 10;}// ...x()+y(); // Unspecified behavior as this may print xy or yx

Many other languages make guarantees that the operands will be evaluated left to right, so the equivalent code in Java is guaranteed to print: xy

Leaving things like these unspecified in C is often done for optimization reasons, so are there any optimizations possible for the compiler to perform when sequence points are not defined between operators such as += and similar?


Viewing all articles
Browse latest Browse all 65

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>