Change description
Currently the fls states that a pointer in a const shall be non-dangling. The compiler accepts a raw dangling pointers in constants.
Area
const evaluation
Category
Bug
FLS Paragraph ID
ls_l1FOH8zt0XRZ
Change description (extended)
fn main() {
// accepted by the compiler
const A: *const u8 = std::ptr::dangling();
const B: *const u8 = std::ptr::null();
// not accepted by the compiler
//const C: &u8 = unsafe { &(*std::ptr::dangling()) };
}
This creates a dangling pointer.
Maybe the text should be changed to say reference instead of pointer?
(i am sorry if i misunderstood the use of "shall". I looked at 1.3.5 and it seems to me that shall is used for rules that the programmer has to follow either to make the compiler accept the program or to avoid UB. But this is both accepted by the compiler and not UB.)
Change description
Currently the fls states that a pointer in a
constshall be non-dangling. The compiler accepts a raw dangling pointers in constants.Area
const evaluation
Category
Bug
FLS Paragraph ID
ls_l1FOH8zt0XRZ
Change description (extended)
This creates a dangling pointer.
Maybe the text should be changed to say
referenceinstead ofpointer?(i am sorry if i misunderstood the use of "shall". I looked at 1.3.5 and it seems to me that shall is used for rules that the programmer has to follow either to make the compiler accept the program or to avoid UB. But this is both accepted by the compiler and not UB.)