2 ms·
-fstrict-aliasing is on by default in gcc at -O2 and above. I'm surprised that the bug discussion doesn't mention that. The PathScale compiler had a fair numbe
by greglindahl 11y ago
-fstrict-aliasing is on by default in gcc at -O2 and above. I'm surprised that the bug discussion doesn't mention that.
The PathScale compiler had a fair number of customers who complained about "bugs" that went away with -fnostrict-aliasing. We told them to use -fnostrict-aliasing.
- Too 11y agoI think it's quite obvious strict aliasing is implied in this case. The bug is than even with strict aliasing he should get the result he wants, because the last time he wrote to the pointer before reading it as an int he wrote it as an int and hence it should keep the int-value 1. Having that said, balancing aliasing like this is just asking for trouble, don't try this at home. EDIT: The more i look at it the more i think he is wrong. Since pi and pd shouldn't be able to alias, the last assignment to both of them is allowed to reorder. This is just UB.