On Fri, 20 Oct 2017, Torvald Riegel wrote: > On Thu, 2017-10-19 at 15:31 +0300, Alexander Monakov wrote: > > On Thu, 19 Oct 2017, Andrew Haley wrote: > > > No, you did not. This looks like a bug. Please report it. > > > > This bug is fixed on trunk, so should work from gcc-8 onwards (PR 80640). > > The test case is invalid (I added some more detail as a comment on this > bug).
Sorry, I was imprecise. To be clear, the issue I referred to above as the "bug [that was] fixed on trunk" is the issue Andrew Haley pointed out: when GCC transitioned from GIMPLE to RTL IR, empty RTL was emitted for the fence statement, losing its compile-time effect as a compiler memory barrier entirely. I agree that the testcase in the opening message of this thread is not valid in the sense that this reordering could not have changed the behavior of a conforming program, but the optimization that GCC performed here was entirely unintentional, not something the compiler is presently designed to do. Alexander