-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Compiler segfaults #17563
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
Comments
I managed to reduce it further, seems like the problem lies with the header file: pub const c = @cImport({
@cDefine("NK_INCLUDE_FIXED_TYPES", "");
@cInclude("nuklear_all.h");
});
pub fn main() !void {
_=c.nk_init(null, null);
} |
Here's the output from a debug build of Zig 0.12.0-dev.985+e44152e25 (it's massive, so I'm not pasting it directly here): https://gist.github.com/ianprime0509/2ab13dac7c2008dce1bb4bcd36d56f82 The following is a more self-contained reproduction of const std = @import("std");
const S = extern struct {
t: T = std.mem.zeroes(T),
};
const T = extern struct {
s: [*c]S = std.mem.zeroes([*c]S),
u: c_uint = std.mem.zeroes(c_uint),
};
test {
const t: T = .{};
_ = t;
}
Debug output for the smaller repro |
Here's a variant of the above repro, this time properly reproducing the original crash: const std = @import("std");
const S = extern struct {
t: T = std.mem.zeroes(T),
};
const T = extern struct {
s: [*c]S = std.mem.zeroes([*c]S),
u: c_uint = std.mem.zeroes(c_uint),
};
const U = extern struct {
s: [*c]S = std.mem.zeroes([*c]S),
};
test {
const u: U = .{};
_ = u;
}
Debug output |
It now compile without crash with latest master |
I spoke too fast, i forgot i had the faulty code commented out.. segfault still happen |
On my branch for this PR #17692, I get the following result:
If I add another |
#17692 has been merged which solves this - the test cases above pass, and the original nuklear test case compiles. |
My project now compile, thanks |
Zig Version
78f2ae7
Steps to Reproduce and Observed Behavior
Initially zig build gave me:
I tried to extract code that causes it from my project
zig build-exe test.zig -I.
OS tested:
Expected Behavior
It should compile, or the compiler should give a proper error message if the code is erroneous
The text was updated successfully, but these errors were encountered: