|
|
|
|
|
by xscott
1080 days ago
|
|
> Strict aliasing is one of the few tools we have to tell the compiler that aliasing will not occur. I can see the argument, but there's a much better way to indicate what you want with your example: void f(int16_t* a, int32_t* b) {
const int16_t a0 = a[0];
for (int32_t i = 0; i < 100; i++) {
b[i] = a0 + i;
}
}
Now a clean (well defined) compiler could do what you asked.I've seen other people suggest that UB is a mechanism to have these magical backdoor conversations with the compiler to express optimization opportunities. I think that's absurd and reckless. Propose adding assertions or "declare" statements instead, and quit thinking of interpretive dance through a minefield as a method of communication. |
|