-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 crash when building code that uses wrong-headed static initialization #20940
Labels
bug
Observed behavior contradicts documented or intended behavior
Comments
AlexMax
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Aug 4, 2024
Reduced version: const std = @import("std");
fn give_me() std.mem.Allocator {
var impl = std.heap.GeneralPurposeAllocator(.{}){};
return impl.allocator();
}
var global = give_me();
pub fn main() void {
_ = &global;
} or fn give_me() *anyopaque {
var x: u8 = 1;
return &x;
}
var global = give_me();
pub fn main() void {
_ = &global;
} Also crashes the compiler with ArenaAllocator, FixedBufferAllocator and FailingAllocator.
|
Debug build of zig gives the following stack trace
|
Duplicate of #20365 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Zig Version
0.14.0-dev.839 a931bfada
Steps to Reproduce and Observed Behavior
This is the contents of
bug.zig
:There are a few problems with the code as written, but the
zig
bug comes in when I attempt to compile this program with:It runs for a bit, then I get another PowerShell prompt without the compiler output being properly cleaned up and an indication from that the last command I tried to run failed. Running
echo $LASTEXITCODE
gives me a line that is half exit code, half uncleaned output:-2147483645Generation
.I am running Windows 11 Version 10.0.22631.3880, and I am using the nightly x64 build of zig.
Expected Behavior
Some sort of error message telling me about the problems with the code.
The text was updated successfully, but these errors were encountered: