Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C99 for-loop defined variable gets incorrect scope #211

Closed
MarcelAtSolidSands opened this issue Dec 11, 2017 · 1 comment
Closed

C99 for-loop defined variable gets incorrect scope #211

MarcelAtSolidSands opened this issue Dec 11, 2017 · 1 comment

Comments

@MarcelAtSolidSands
Copy link

We found a run-time error with SuperTest for the program below. The program should print 100 for the value of 'press', but when compiled with CompCert 3.1 on an x86 Apple Mac, it prints 3. It looks like CompCert is confused about the scopes of the two variables called 'press'.

===========================================

#include <stdio.h>

int press = 100;
int valve = 0;

int main (void) {
for (int press = 0; press < 3; press++) {
valve++;
}
printf ("Value of 'press' should be 100, is: %d\n", press);
return valve - 3;
}

bschommer added a commit that referenced this issue Dec 12, 2017
* Do not pass the env back from for stmt decls.

This is the source of issue #211, the environment from the elaboration of
the declaration and expressions in the for loop should not be passed back.
@bschommer
Copy link
Member

Should be fixed by 6753e8f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants