twittidai / picoc

Automatically exported from code.google.com/p/picoc
0 stars 0 forks source link

Define macro inside a function block will crash picoc #192

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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 christop...@gmail.com on 28 Feb 2014 at 2:06

GoogleCodeExporter commented 8 years ago
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 m...@heilpern.com on 28 Feb 2014 at 2:12

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r605.

Original comment by zik.sale...@gmail.com on 1 Mar 2014 at 2:54

GoogleCodeExporter commented 8 years ago
Thanks for the bug report. This was a tricky one.

It's fixed in r605.

Original comment by zik.sale...@gmail.com on 1 Mar 2014 at 2:55

GoogleCodeExporter commented 8 years ago
@zik -- not quite fixed... please see issue 193.

Original comment by m...@heilpern.com on 3 Mar 2014 at 9:32