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

Weird issues with referencing top-level variables in functions #482

Open
nshaheed opened this issue Dec 10, 2024 · 1 comment
Open

Weird issues with referencing top-level variables in functions #482

nshaheed opened this issue Dec 10, 2024 · 1 comment
Assignees
Labels

Comments

@nshaheed
Copy link
Contributor

There's some weird incorrect behavior when defining a function that references top level variables that are declared later in the code:

fun void foo() {
    // 1 => bar; // 
    <<< bar >>>;
    <<< baz >>>;
}


10 => int bar;
SinOsc baz;

foo();

samp => now;

this outputs:

-274171104 :(int) // this should be 10
0x556cefa87b20 :(SinOsc|refcount=6)

And doing this:

fun void foo() {
    1 => bar;
    <<< bar >>>;
    <<< baz >>>;
}


10 => int bar;
SinOsc baz;

foo();

samp => now;

means that bar outputs correctly, but printing baz causes a segfault:

1 :(int)
Segmentation fault (core dumped)

Putting foo() after the variable declarations makes the problem go away. Maybe it's something with stack pointers being pushed incorrectly?

@nshaheed nshaheed added the bug label Dec 10, 2024
@gewang
Copy link
Member

gewang commented Dec 11, 2024

this has been fixed in 4f27aef (and now tested on the programs above)

@gewang gewang self-assigned this Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants