diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2022-10-10 00:47:45 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2022-10-25 05:11:29 -0400 |
| commit | 5eafc10bf41451fb694f324dcaefe5c458e1ca3a (patch) | |
| tree | 45ee1879f0a2b0b6b198cb4136f04e5cc1868de9 /src/codegen/c.zig | |
| parent | c126a1018eec54c568aaa642013e3c86bdd6d3e4 (diff) | |
| download | zig-5eafc10bf41451fb694f324dcaefe5c458e1ca3a.tar.gz zig-5eafc10bf41451fb694f324dcaefe5c458e1ca3a.zip | |
cbe: fix global access fix
Diffstat (limited to 'src/codegen/c.zig')
| -rw-r--r-- | src/codegen/c.zig | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index d479f30e60..e3391c450a 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -393,7 +393,10 @@ pub const DeclGen = struct { val: Value, decl_index: Decl.Index, ) error{ OutOfMemory, AnalysisFail }!void { - if (ty.isPtrAtRuntime() and !ty.elemType2().isFnOrHasRuntimeBits()) { + const decl = dg.module.declPtr(decl_index); + assert(decl.has_tv); + + if (ty.isPtrAtRuntime() and !decl.ty.isFnOrHasRuntimeBits()) { return dg.writeCValue(writer, CValue{ .undefined_ptr = ty }); } @@ -409,8 +412,6 @@ pub const DeclGen = struct { return; } - const decl = dg.module.declPtr(decl_index); - assert(decl.has_tv); // We shouldn't cast C function pointers as this is UB (when you call // them). The analysis until now should ensure that the C function // pointers are compatible. If they are not, then there is a bug |
