fixed #2356
const_ptr_pointee_unchecked did not take into account that if the pointer is zero sized, then const_val->data.x_ptr.special would be ConstPtrSpecialInvalid. This commit fixes this by also checking that the child type of the pointer only have one possible value and just returns that value.
This commit is contained in:
13
src/ir.cpp
13
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();
|
||||
|
||||
Reference in New Issue
Block a user