authorgravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2019-04-24 18:42:55+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-04-24 18:42:55+02:00
loge4a86d4653c5854437371e2b63006bd4a1b4c83d
tree66fcb47280ed14f33e86deb805be79f9497bc537
parente553ade090582d7f863e2f02e6e0c803d4b9408b
parent1a2e02e267216bb35937d25598c773255d830b25
signature Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #2351 from ziglang/fixed-2346

fixes #2346

3 files changed, 20 insertions(+), 0 deletions(-)

src/ir.cpp+13
......@@ -188,6 +188,19 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c
188188 assert(get_src_ptr_type(const_val->type) != nullptr);
189189 assert(const_val->special == ConstValSpecialStatic);
190190 ConstExprValue *result;
191
192 switch (type_has_one_possible_value(g, const_val->type->data.pointer.child_type)) {
193 case OnePossibleValueInvalid:
194 zig_unreachable();
195 case OnePossibleValueYes:
196 result = create_const_vals(1);
197 result->type = const_val->type->data.pointer.child_type;
198 result->special = ConstValSpecialStatic;
199 return result;
200 case OnePossibleValueNo:
201 break;
202 }
203
191204 switch (const_val->data.x_ptr.special) {
192205 case ConstPtrSpecialInvalid:
193206 zig_unreachable();
test/stage1/behavior.zig+1
......@@ -24,6 +24,7 @@ comptime {
2424 _ = @import("behavior/bugs/1851.zig");
2525 _ = @import("behavior/bugs/1914.zig");
2626 _ = @import("behavior/bugs/2006.zig");
27 _ = @import("behavior/bugs/2346.zig");
2728 _ = @import("behavior/bugs/394.zig");
2829 _ = @import("behavior/bugs/421.zig");
2930 _ = @import("behavior/bugs/529.zig");
test/stage1/behavior/bugs/2346.zig created+6
......@@ -0,0 +1,6 @@
1test "" {
2 const a: *void = undefined;
3 const b: *[1]void = a;
4 const c: *[0]u8 = undefined;
5 const d: []u8 = c;
6}
\ No newline at end of file