3 ms·
If payload was ever dereferenced as a char array as well, I would buy the strict aliasing argument. But it’s not, it exists as a char pointer solely for pointer
by drdexebtjl 1mo ago
If payload was ever dereferenced as a char array as well, I would buy the strict aliasing argument. But it’s not, it exists as a char pointer solely for pointer arithmetic.
AFAIK The purpose of strict aliasing rules is to let the compiler assume that dereferencing pointers of different types never refer to the same memory.
If ISO C treats this as UB, shouldn’t ISO C be fixed?
- dcrazy 1mo agoNo, you should fix your code to be compliant with ISO C. The optimizer isn’t going to wait for you to convince WG14.
- drdexebtjl 1mo agoI’m not chasing theoretical portability and checking off a box saying my code is 100% pure ISO C. If that’s important to you, don’t do this (and also don’t use pretty much any allocator!) Every sufficiently useful C codebase assumes specific implementations.