3 ms·
This isn't legacy cruft though, imagine having hardware that has tag bits what happens when I do int a = 0; uintptr_t *b = &a?
by nwmcsween 10y ago
This isn't legacy cruft though, imagine having hardware that has tag bits what happens when I do int a = 0; uintptr_t *b = &a?
- jjnoakes 10y agoWhat happens is that would be a type violation and not compile. And if you insert the cast, that's fine, my vision of modern C wouldn't stop you. It will do what you expect it to: write bytes directly to the memory. If it traps later so be it. What my modern c would not do is eliminate some code later or nasal demons because it thinks some path of code could income undefined behavior. I basically agree with "friendly C": undefined behavior should be redefined to mean "unspecified but not unexpected behavior" in line with the target architecture semantics. Don't expect portability if you break the rules, but expect something that resembles a reasonable mapping from what you wrote to what the machine semantics are.