https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104800
--- Comment #8 from Martin Uecker <muecker at gwdg dot de> --- The standard specifies in 5.1.2.3p6 that "— Volatile accesses to objects are evaluated strictly according to the rules of the abstract machine." and "This is the observable behavior of the program." If a trap is moved before a volatile access so that the access never happens, than this changes the observable behavior because the volatile access was then not evaluated strictly according to the abstract machine. Some people argue that this is OK because the trap is undefined behavior, but I do not see how this follows from the C standard. It defines undefined behavior as "behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which this document imposes no requirements" This states that there are no requirements on what undefined operation can do. But I do not see how this allows changing other previous defined behavior mandated by the standard. Now, we could make it clear in the C standard that UB invalidates the complete program (as in C++), but to me it is obvious that this is dangerous and it increasingly becomes clear that this also causes other problems.*) It would rather have some more restricted notion of UB and the volatile cases in GCC fixed. *) For example, it is problematic if UB is allowed to affect previous atomic operations.