Hacker News new | ask | show | jobs
by oriolid 10 days ago
> Can it turn x++,x++ into x+=2

For this particular example the line should be clear. If the variable is volatile, memory access can't be removed or reordered. If it's not volatile, everything is fair game.

Mandatory Godbolt link: https://godbolt.org/z/fjKs4hbjo

1 comments

It’s clear by the language spec. It’s not clear based on how people want it to work or think it should work. And the inevitable stream of comments complaining about C compiler optimizers every time this gets discussed tells us that people are not willing to just consider where the language spec draws the line.