> Date: Thu, 10 Mar 2022 23:09:59 +0000 > From: Laurence Tratt <[email protected]> > > On Fri, Mar 11, 2022 at 09:00:57AM +1000, David Gwynne wrote: > > Hello David, > > >> Unfortunately this transformation almost certainly isn't safe: for > >> example, the non-atomic load can return values that were never written by > >> any thread (e.g. due to load/store tearing amongst other fun effects). > > is that true even when care is taken to only use int/long sized variables > > that are naturally aligned? are compilers that pathological now? > > Yes and yes, I'm afraid -- though rare, there are real examples of compilers > doing this (pity the poor person who debugs it!). My working guess is that > they'll be increasingly likely to occur as compilers become ever more > aggressive at taking advantage of undefined behaviour. > > Jade Alglave et al. did an approachable intro to many (all?) of the horrors > one might observe in the context of the Linux kernel [1], which is worth a > read IMHO.
Such a compiler is broken beyond repair. > [1] https://lwn.net/Articles/793253/ > >
