rui314 / 8cc

A Small C Compiler
MIT License
6.12k stars 742 forks source link

Compound assignment lvalue evaluated twice. #66

Open andrewchambers opened 9 years ago

andrewchambers commented 9 years ago

From standard: 6.5.16.2 Compound assignment

A compound assignment of the form E1 op= E2 is equivalent to the simple assignment expression E1  =  E1 op (E2) , except that the lvalue E1 is evaluated only once

Looking at the code, we are evaluating the lvalue twice, so things like side affecting functions on the lhs will be called twice.