| author | |
| committer | |
| log | fffb0904f898d47800aa418085dc6064d02c32fe |
| tree | c29e9ba6d134117372b6dd088637ff947068cef5 |
| parent | 8aab1e2e8ad1451a22a48109006babf463a09e9e |
Make sure the child element is not undefined, let's catch this problem
early on.
Closes #75682 files changed, 11 insertions(+), 1 deletions(-)
src/stage1/ir.cpp+1-1| ... | ... | @@ -13763,7 +13763,7 @@ static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstGen *type_value) { |
| 13763 | 13763 | |
| 13764 | 13764 | Error err; |
| 13765 | 13765 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, type_value->base.source_node, |
| 13766 | type_value->value, LazyOk))) | |
| 13766 | type_value->value, LazyOkNoUndef))) | |
| 13767 | 13767 | { |
| 13768 | 13768 | return nullptr; |
| 13769 | 13769 | } |
test/compile_errors.zig+10| ... | ... | @@ -2,6 +2,16 @@ const tests = @import("tests.zig"); |
| 2 | 2 | const std = @import("std"); |
| 3 | 3 | |
| 4 | 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5 | cases.add("lazy pointer with undefined element type", | |
| 6 | \\export fn foo() void { | |
| 7 | \\ comptime var T: type = undefined; | |
| 8 | \\ const S = struct { x: *T }; | |
| 9 | \\ const I = @typeInfo(S); | |
| 10 | \\} | |
| 11 | , &[_][]const u8{ | |
| 12 | "tmp.zig:3:28: error: use of undefined value here causes undefined behavior", | |
| 13 | }); | |
| 14 | ||
| 5 | 15 | cases.add("pointer arithmetic on pointer-to-array", |
| 6 | 16 | \\export fn foo() void { |
| 7 | 17 | \\ var x: [10]u8 = undefined; |