aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-06-09 15:09:16 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-06-09 15:09:48 -0700
commitf1cff4fa4a28d42ac9055f94ee9a8f7fd2831cd7 (patch)
tree60c9d5d3067036582a137ac1f57fdbe167fb7855
parenta3f05b80f1c26ca905e01c6d3a8a288a9f1d9e25 (diff)
downloadzig-f1cff4fa4a28d42ac9055f94ee9a8f7fd2831cd7.tar.gz
zig-f1cff4fa4a28d42ac9055f94ee9a8f7fd2831cd7.zip
Sema: avoid use of undefined value for generic fn calls
I saw some issues in Valgrind which are fixed after this commit.
-rw-r--r--src/Sema.zig11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index d64b067771..2d3c38faeb 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -7026,9 +7026,14 @@ fn funcCommon(
});
};
- // stage1 bug workaround
- const cc_workaround = cc orelse undefined;
- const align_workaround = alignment orelse @as(u32, undefined);
+ // These locals are pulled out from the init expression below to work around
+ // a stage1 compiler bug.
+ // In the case of generic calling convention, or generic alignment, we use
+ // default values which are only meaningful for the generic function, *not*
+ // the instantiation, which can depend on comptime parameters.
+ // Related proposal: https://github.com/ziglang/zig/issues/11834
+ const cc_workaround = cc orelse .Unspecified;
+ const align_workaround = alignment orelse 0;
break :fn_ty try Type.Tag.function.create(sema.arena, .{
.param_types = param_types,