3 ms·
I would think that modifying a pointer to a const object, e.g. const int x = 123; const int *px = &x; (*(int*)px) = 456; is very, very UB in C (an
by jcelerier 4y ago
I would think that modifying a pointer to a const object, e.g.
const int x = 123;
const int *px = &x;
(*(int*)px) = 456;
is very, very UB in C (and most likely will crash on most platforms)
- nyanpasu64 4y agoint x = 123; const int *px = &x; (*(int*)px) = 456; is legal in C. The Rust equivalent using & and &mut is UB. Writing this in Rust using raw pointers requires unsafe blocks everywhere, loses method syntax, has no -> operator, etc.