diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2025-01-05 04:59:31 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-01-05 17:15:56 -0500 |
| commit | 0bf44c30934bced6fc8f6451cf418ae40db665e6 (patch) | |
| tree | c9d715c9907060ef77c1cd807c3ce42e1e133f15 /test | |
| parent | 137787edbb1320ce50bd4193d69f21ffaf8593e8 (diff) | |
| download | zig-0bf44c30934bced6fc8f6451cf418ae40db665e6.tar.gz zig-0bf44c30934bced6fc8f6451cf418ae40db665e6.zip | |
x86_64: fix `@errorName` data
The final offset was clobbering the first error name, which is revealed
by an out of bounds when the global error set is empty.
Closes #22362
Diffstat (limited to 'test')
| -rw-r--r-- | test/standalone/build.zig.zon | 3 | ||||
| -rw-r--r-- | test/standalone/empty_global_error_set/build.zig | 24 | ||||
| -rw-r--r-- | test/standalone/empty_global_error_set/main.zig | 4 |
3 files changed, 31 insertions, 0 deletions
diff --git a/test/standalone/build.zig.zon b/test/standalone/build.zig.zon index 30ec07823b..06ebe980d1 100644 --- a/test/standalone/build.zig.zon +++ b/test/standalone/build.zig.zon @@ -180,6 +180,9 @@ .run_output_caching = .{ .path = "run_output_caching", }, + .empty_global_error_set = .{ + .path = "empty_global_error_set", + }, }, .paths = .{ "build.zig", diff --git a/test/standalone/empty_global_error_set/build.zig b/test/standalone/empty_global_error_set/build.zig new file mode 100644 index 0000000000..ad971aa6d1 --- /dev/null +++ b/test/standalone/empty_global_error_set/build.zig @@ -0,0 +1,24 @@ +const std = @import("std"); +const builtin = @import("builtin"); + +pub fn build(b: *std.Build) void { + const test_step = b.step("test", "Test it"); + b.default_step = test_step; + + for ([_]bool{ false, true }) |use_llvm| { + const main = b.addObject(.{ + .name = "main", + .root_module = b.createModule(.{ + .root_source_file = b.path("main.zig"), + .target = b.resolveTargetQuery(.{ + .cpu_arch = .x86_64, + .os_tag = .linux, + }), + }), + .use_llvm = use_llvm, + .use_lld = use_llvm, + }); + _ = main.getEmittedBin(); + test_step.dependOn(&main.step); + } +} diff --git a/test/standalone/empty_global_error_set/main.zig b/test/standalone/empty_global_error_set/main.zig new file mode 100644 index 0000000000..ecf7cf5167 --- /dev/null +++ b/test/standalone/empty_global_error_set/main.zig @@ -0,0 +1,4 @@ +fn errorName(err: anyerror) [:0]const u8 { + return @errorName(err); +} +export const error_name: *const anyopaque = &errorName; |
