-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Open
Labels
C-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorS-Needs-TriageThis issue needs to be labelledThis issue needs to be labelled
Description
Bevy version
0.16 and commit f964ee1
What you did
use bevy_ecs::prelude::*;
#[derive(Component)]
struct A(usize);
#[derive(Component)]
struct B(&'static u8);
let mut world1 = World::new();
let e = world1.spawn(A(0x1)).id();
let mut world2 = World::new();
world2.register_component::<B>();
std::mem::swap(
&mut *world1.components_registrator(),
&mut *world2.components_registrator(),
);
let e = world1.entity(e).get::<B>().unwrap().0;
println!("{e}"); // will try to dereference the address 0x1
What went wrong
The code was accepted and at runtime a component is accessed with the wrong type, leading to UB.
Metadata
Metadata
Assignees
Labels
C-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorS-Needs-TriageThis issue needs to be labelledThis issue needs to be labelled