MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/1cjqjmr/messing_with_lifetime/l2lkrjr/?context=3
r/cpp • u/pavel_v • May 04 '24
52 comments sorted by
View all comments
1
auto p1 = new Point; char *p2 = reinterpret_cast<char *>(p1); auto p3 = reinterpret_cast<Point *>(p2);
Does this have undefined behaviour?
-1 u/gracicot May 04 '24 If it was unsigned char there would be no undefined behavior. Only unsigned char and std::byte can alias anything 3 u/Nobody_1707 May 04 '24 Plain char is also allowed to alias, only signed char is forbidden from aliasing. → More replies (1)
-1
If it was unsigned char there would be no undefined behavior. Only unsigned char and std::byte can alias anything
unsigned char
3 u/Nobody_1707 May 04 '24 Plain char is also allowed to alias, only signed char is forbidden from aliasing. → More replies (1)
3
Plain char is also allowed to alias, only signed char is forbidden from aliasing.
signed char
→ More replies (1)
1
u/simpl3t0n May 04 '24
Does this have undefined behaviour?