accept undef in raw pointers, for consistency with integers

This commit is contained in:
Ralf Jung 2018-11-17 14:05:00 +01:00
parent 261faf3ce2
commit fb8b1e3989

View File

@ -312,12 +312,16 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>
} }
} }
ty::RawPtr(..) => { ty::RawPtr(..) => {
// No undef allowed here. Eventually this should be consistent with if self.const_mode {
// the integer types. // Integers/floats in CTFE: For consistency with integers, we do not
let _ptr = try_validation!(value.to_scalar_ptr(), // accept undef.
"undefined address in pointer", self.path); let _ptr = try_validation!(value.to_scalar_ptr(),
let _meta = try_validation!(value.to_meta(), "undefined address in raw pointer", self.path);
"uninitialized data in fat pointer metadata", self.path); let _meta = try_validation!(value.to_meta(),
"uninitialized data in raw fat pointer metadata", self.path);
} else {
// Remain consistent with `usize`: Accept anything.
}
} }
_ if ty.is_box() || ty.is_region_ptr() => { _ if ty.is_box() || ty.is_region_ptr() => {
// Handle fat pointers. // Handle fat pointers.