commit e4a86d4653c5854437371e2b63006bd4a1b4c83d (tree)
parent e553ade090582d7f863e2f02e6e0c803d4b9408b
Author: Jimmi Holst Christensen <jhc@dismail.de>
Date: Wed, 24 Apr 2019 18:42:55 +0200
Merge pull request #2351 from ziglang/fixed-2346
fixes #2346
Diffstat:
3 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/src/ir.cpp b/src/ir.cpp
@@ -188,6 +188,19 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c
assert(get_src_ptr_type(const_val->type) != nullptr);
assert(const_val->special == ConstValSpecialStatic);
ConstExprValue *result;
+
+ switch (type_has_one_possible_value(g, const_val->type->data.pointer.child_type)) {
+ case OnePossibleValueInvalid:
+ zig_unreachable();
+ case OnePossibleValueYes:
+ result = create_const_vals(1);
+ result->type = const_val->type->data.pointer.child_type;
+ result->special = ConstValSpecialStatic;
+ return result;
+ case OnePossibleValueNo:
+ break;
+ }
+
switch (const_val->data.x_ptr.special) {
case ConstPtrSpecialInvalid:
zig_unreachable();
diff --git a/test/stage1/behavior.zig b/test/stage1/behavior.zig
@@ -24,6 +24,7 @@ comptime {
_ = @import("behavior/bugs/1851.zig");
_ = @import("behavior/bugs/1914.zig");
_ = @import("behavior/bugs/2006.zig");
+ _ = @import("behavior/bugs/2346.zig");
_ = @import("behavior/bugs/394.zig");
_ = @import("behavior/bugs/421.zig");
_ = @import("behavior/bugs/529.zig");
diff --git a/test/stage1/behavior/bugs/2346.zig b/test/stage1/behavior/bugs/2346.zig
@@ -0,0 +1,6 @@
+test "" {
+ const a: *void = undefined;
+ const b: *[1]void = a;
+ const c: *[0]u8 = undefined;
+ const d: []u8 = c;
+}
+\ No newline at end of file