authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-09 15:09:16-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-09 15:09:48-07:00
logf1cff4fa4a28d42ac9055f94ee9a8f7fd2831cd7
tree60c9d5d3067036582a137ac1f57fdbe167fb7855
parenta3f05b80f1c26ca905e01c6d3a8a288a9f1d9e25

Sema: avoid use of undefined value for generic fn calls

I saw some issues in Valgrind which are fixed after this commit.

1 files changed, 8 insertions(+), 3 deletions(-)

src/Sema.zig+8-3
...@@ -7026,9 +7026,14 @@ fn funcCommon(...@@ -7026,9 +7026,14 @@ fn funcCommon(
7026 });7026 });
7027 };7027 };
70287028
7029 // stage1 bug workaround7029 // These locals are pulled out from the init expression below to work around
7030 const cc_workaround = cc orelse undefined;7030 // a stage1 compiler bug.
7031 const align_workaround = alignment orelse @as(u32, undefined);7031 // In the case of generic calling convention, or generic alignment, we use
7032 // default values which are only meaningful for the generic function, *not*
7033 // the instantiation, which can depend on comptime parameters.
7034 // Related proposal: https://github.com/ziglang/zig/issues/11834
7035 const cc_workaround = cc orelse .Unspecified;
7036 const align_workaround = alignment orelse 0;
70327037
7033 break :fn_ty try Type.Tag.function.create(sema.arena, .{7038 break :fn_ty try Type.Tag.function.create(sema.arena, .{
7034 .param_types = param_types,7039 .param_types = param_types,