43 ms·
But any optimizing compiler is surely going to assume its memory model is adhered to, no? Therefore any "data races" will be undefined behaviour (even if they'r
by ChrisSD 6y ago
But any optimizing compiler is surely going to assume its memory model is adhered to, no? Therefore any "data races" will be undefined behaviour (even if they're atomic on physical hardware).
- jfkebwjsbx 6y ago"Any" and "surely" are very strong words! Compilers implement different kinds of languages, guarantees, extensions and what not. Even if your program is not conforming to whatever standard, it may be very well be useful and working in most compilers out there. As an example, Linux is not conforming C, including triggering UB. But at least two major compilers support the intended semantics even if they are forbidden by the standard.
- ChrisSD 6y agoUB is UB. It might work. It might work now but not in the future. It might work in some situation but not others. It might appear to work but introduce subtle bugs elsewhere in the program. Linux, as Linus has said, isn't written in ISO C it's written (or was) in GNU C. The two had something of a symbiotic relationship for a long time. Which is why porting it to LLVM was such a tremendous effort. Which is to say, Linux conforms to the memory model of the compilers it compiles on (or vice versa). Not ISO C's memory model. So I'm not sure how your example is relevant.
- steerablesafe 6y agoLinux arguably relies on compiler extensions. Compilers are allowed to define behavior that is undefined by the language standards, effectively extending the language.
- gpderetta 6y agoThere has been a significant push to get Linux to use the c11 conformant gcc builtins. There has been significant push back though, but at least some bits have been updated.