-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
As noted here: #4 (comment)
There is a slight issue with the scoping logic for pointers using the same variable name for verses, stanzas, and poems. Here's an example script that shows the issue:
#include "stdio.h"
#include "stdlib.h"
int main(){
int n = 0;
int *c = calloc(1, sizeof(int));
c[0] = 5;
printf("C: %d\n", c[0]);
{
int *a = c;
a[0] = 100;
int n = 1;
printf("%d\n", n);
}
printf("C: %d\n", c[0]);
printf("%d\n", n);
return 0;
}
Essentially, we need to define a new variable for pointers (in this case c -> a for internal blocks. Because we use thismethod for creating prologues for verses and stanzas, there is a possibility that users will use the same variabe (c in this case), which will cause a segfault when using c[0] (instead of a[0]) in the inner block.
The quick fix for now is simply to make sure that the variable names in all stanza, verse, and poem arguments are unique.
Metadata
Metadata
Assignees
Labels
No labels