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

Define macro inside a function block will crash picoc #192

Closed
GoogleCodeExporter opened this issue Oct 14, 2015 · 4 comments
Closed

Define macro inside a function block will crash picoc #192

GoogleCodeExporter opened this issue Oct 14, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Save this code in source.c:
void printArray(void) {
#define SIZE 10
   int array[SIZE] = {5, 4, 3, 9, 1, 8, 6, 7, 5, 2};
   printf("4: %d\n", array[4]);
}
printArray();

2. Run picoc -s source.c


What is the expected output? What do you see instead?
Expected: 4: 1
What I see: segmentation fault

What version of the product are you using? On what operating system?
r603 on Windows 7, compile with MS Visual Studio

Please provide any additional information below.

The following code will work:

#define SIZE 10
void printArray(void) {
   int array[SIZE] = {5, 4, 3, 9, 1, 8, 6, 7, 5, 2};
   printf("4: %d\n", array[4]);
}
printArray();

Original issue reported on code.google.com by [email protected] on 28 Feb 2014 at 2:06

@GoogleCodeExporter
Copy link
Author

I've also seen this under OS X (and since my other reports generally say I've 
duplicated a problem under Linux, I'll add that my lack of saying that doesn't 
mean it works under Linux, just that I haven't tried).

Original comment by [email protected] on 28 Feb 2014 at 2:12

@GoogleCodeExporter
Copy link
Author

This issue was closed by revision r605.

Original comment by [email protected] on 1 Mar 2014 at 2:54

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Thanks for the bug report. This was a tricky one.

It's fixed in r605.

Original comment by [email protected] on 1 Mar 2014 at 2:55

  • Changed state: Verified

@GoogleCodeExporter
Copy link
Author

@zik -- not quite fixed... please see issue 193.

Original comment by [email protected] on 3 Mar 2014 at 9:32

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

No branches or pull requests

1 participant