News for hackers. Stuff that matters.
Re:Wrong optimization with aliasing by greglindahl on Tuesday February 16, 2016 @12:54AM (#11108146)
-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.

Re:Wrong optimization with aliasing by Too on Tuesday February 16, 2016 @03:23AM (#11108548)
I 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.