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

Compiler crashes when using the a,b=b,a syntax on large arrays #3629

Open
hstormo opened this issue May 25, 2024 · 3 comments
Open

Compiler crashes when using the a,b=b,a syntax on large arrays #3629

hstormo opened this issue May 25, 2024 · 3 comments

Comments

@hstormo
Copy link
Contributor

hstormo commented May 25, 2024

Context

        Odin:    dev-2024-05:d698d4cda
        OS:      Windows 11 Enterprise (version: 23H2), build 22631.3296
        CPU:     AMD Ryzen 7 5800X 8-Core Processor
        RAM:     16310 MiB
        Backend: LLVM 17.0.1
package main

a, b: [100000]int

main :: proc() {
    a, b = b, a
}

Expected Behavior

The program should compile, probably with a "possible stack overflow" warning like it does if you declare a large array as local variable.

Current Behavior

The compiler crashes.

Steps to Reproduce

Compile the code above.

@hstormo
Copy link
Contributor Author

hstormo commented May 25, 2024

Tried in the debugger, shows segfault in llvm call.

image

@hstormo hstormo changed the title Compiler silently exits when using the a,b=b,a syntax on large arrays Compiler crashes when using the a,b=b,a syntax on large arrays May 25, 2024
@gingerBill
Copy link
Member

This isn't a bug per se, but rather just a possible stack overflow. So it's a question how would you warn about such a thing in the first place?

@hstormo
Copy link
Contributor Author

hstormo commented May 25, 2024

Well, if I swap the arrays the "traditional" way with a temporary variable, like t := a; a = b; b = t it compiles fine with a warning: Warning: Declaration of 't' may cause a stack overflow due to its type '[100000]int' having a size of 800000 bytes So I assumed the same would be possible with the special syntax. But I don't know how it's actually implemented.

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

No branches or pull requests

2 participants