Fix compiler crash when passing a comptime extern function arg to a function#24249
Conversation
|
I don't think this is correct, see: fn foo(f: fn () callconv(.C) void) void {
_ = f;
}
pub fn main() !void {
foo(@extern(*const fn () callconv(.c) void, .{ .name = "func" }).*);
} |
f6c0449 to
1633e8c
Compare
|
|
1633e8c to
3918244
Compare
|
|
|
Also if you look at the debug info for export fn entry() void {
_ = @TypeOf(foo).ef;
}
threadlocal var foo: T: {
const e = @extern(*const fn () callconv(.c) void, .{ .name = "an_extern_function" }).*;
break :T struct {
x: u32,
const ef = e;
};
} = .{ .x = 0 }; |
3918244 to
abbd952
Compare
|
Thank you for your help and patience @jacobly0. After thinking it over I realised I was a bit confused and came at the problem from the wrong direction. I think the correct thing to do is to just not emit debug info for any extern functions or variables. This seems to be more inline with what all previous code is trying to do and how this is handled in C. Correct me if I'm wrong but we don't actually need this debug info as we get it from whatever library exported the function or variable. master currently emits DW_TAG_variable for extern functions as well. |
|
Master does not implement extern functions at all, hence all of these crashes, it's just falling into the extern variable handling. As Zig has namespaced extern declarations (not |
40999cc to
8ce37ee
Compare
702c3e7 to
351b4de
Compare
351b4de to
52178d1
Compare
This PR fixes a compiler crash that occurs when passing a comptime extern function argument to a function.
The compiler crashes in DWARF debug info code.
The function getValueEntry does not handle extern functions correctly, instead handling all values with a function type asInternPool.Key.funcvalues.Repro
Code
Stack trace
Closes #24259