You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#![feature(arbitrary_self_types)]use std::ptr;traitFoo{fnfoo(self:*constSelf) -> &'static str;}implFoofori32{fnfoo(self:*constSelf) -> &'static str{"I'm an i32!"}}implFooforu32{fnfoo(self:*constSelf) -> &'static str{"I'm a u32!"}}fnmain(){let null_i32 = ptr::null::<i32>()as*constdynFoo;let null_u32 = ptr::null::<u32>()as*constdynFoo;assert_eq!("I'm an i32!",null_i32.foo());assert_eq!("I'm a u32!",null_u32.foo());}
error: Undefined Behavior: dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
--> src/main.rs:24:31
|
24 | assert_eq!("I'm an i32!", null_i32.foo());
| ^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `main` at src/main.rs:24:31: 24:45
Given that this is all safe code, definitely something is wrong here. I am not sure why there is a pointer deref, this might have to do with internals of dyn receiver handling.
The text was updated successfully, but these errors were encountered:
This code reports UB:
Given that this is all safe code, definitely something is wrong here. I am not sure why there is a pointer deref, this might have to do with internals of dyn receiver handling.
The text was updated successfully, but these errors were encountered: