We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
A buffer placed in the scope of a switch statement results in memory corruption. The following code:
#include <stdio.h> int main(void) { /* char switchbuf[32]; // Placing the buffer here works fine */ int a=1234; printf("a: %d\n", a); switch (a) { char switchbuf[32]; case 1234: printf("a: %d\n", a); break; } printf("a: %d\n", a); return 0; }
results in the output:
a: 1234 a: 0 a: 0
when it should result in:
a: 1234 a: 1234 a: 1234
Moving the switchbuf variable outside the switch statement works as expected.
switchbuf
This is using the code from git from about 2 months ago.
The text was updated successfully, but these errors were encountered:
The test program was compiled with zcc +cpm -create-app switchvar.c I've confirmed that the problem still exists with at HEAD 162135b.
zcc +cpm -create-app switchvar.c
Sorry, something went wrong.
Impressive edge case - I've not come across code that does that.
It may take me a while to figure out how to solve this one nicely.
Speaking of edge cases, I should see if zcc supports Duff's device ☺
I believe it does!
No branches or pull requests
A buffer placed in the scope of a switch statement results in memory corruption. The following code:
results in the output:
when it should result in:
Moving the
switchbuf
variable outside the switch statement works as expected.This is using the code from git from about 2 months ago.
The text was updated successfully, but these errors were encountered: