rust/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr

21 lines
1.7 KiB
Plaintext
Raw Normal View History

error: pointers cannot be compared in a meaningful way during const eval.
--> $DIR/const_raw_ptr_ops.rs:4:26
|
2019-03-09 06:03:44 -06:00
LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: It is conceptually impossible for const eval to know in all cases whether two pointers are equal. While sometimes it is clear (the address of a static item is never equal to the address of another static item), comparing an integer address with any allocation's address is impossible to do at compile-time.
= note: That said, there's the `ptr_maybe_eq` intrinsic which returns `true` for all comparisons where CTFE isn't sure whether two addresses are equal. The mirror intrinsic `ptr_maybe_ne` returns `true` for all comparisons where CTFE isn't sure whether two addresses are inequal.
error: pointers cannot be compared in a meaningful way during const eval.
--> $DIR/const_raw_ptr_ops.rs:6:27
|
LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: It is conceptually impossible for const eval to know in all cases whether two pointers are equal. While sometimes it is clear (the address of a static item is never equal to the address of another static item), comparing an integer address with any allocation's address is impossible to do at compile-time.
= note: That said, there's the `ptr_maybe_eq` intrinsic which returns `true` for all comparisons where CTFE isn't sure whether two addresses are equal. The mirror intrinsic `ptr_maybe_ne` returns `true` for all comparisons where CTFE isn't sure whether two addresses are inequal.
error: aborting due to 2 previous errors