mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-15 23:18:48 +00:00
Update model solution.
- Stop calculating operands for & operators. - Evaluate the lhs of compound operators only once. - Add `side-effect.c` example.
This commit is contained in:
13
examples/c/side_effect.c
Normal file
13
examples/c/side_effect.c
Normal file
@@ -0,0 +1,13 @@
|
||||
int g = 0;
|
||||
|
||||
int* foo() {
|
||||
g += 10;
|
||||
return &g;
|
||||
}
|
||||
|
||||
int main() {
|
||||
// `foo()` should be called once.
|
||||
*&*foo() += 1;
|
||||
|
||||
return g;
|
||||
}
|
||||
Reference in New Issue
Block a user