5 ms·
I'm curious if what you mean is that C++11 has a standard spec for the memory model you describe, but if Linux doesn't use it, then Linux does not actually adhe
by hellofunk 11y ago
I'm curious if what you mean is that C++11 has a standard spec for the memory model you describe, but if Linux doesn't use it, then Linux does not actually adhere to the C++11 standard? Does that mean that Linux C++11 compilers are non-standard in general?
- Manishearth 11y agoI don't think there are any (modern) C++ compilers out there which follow the standard 100% and perfectly. ICBW.
- hellofunk 11y agoI think you're mistaken: http://clang.llvm.org/cxx_status.html#cxx11 http://clang.llvm.org/cxx_status.html#cxx11
- Manishearth 11y agoThat's a list of features. My point was that there are some slight variations induced by optimizations or otherwise which are against the spec.
- hellofunk 11y agoI think you are confusing specification with implementation. The C++ standard does not outline how a compiler implements a feature, just how it should behave to match the standard. There are several compilers that 100% adhere to the full standard, including the guarantees specified by the standard in the form of memory and time complexity (optimization).
- Manishearth 11y agoOh, I know that specification != implementation, but IIRC both clang and GCC have certain behaviour which do not conform to the standard. But I can't find these right now, so I'll drop it here :)
- haberman 11y agoLet me clarify first that when I say "Linux" in this post, I'm specifically referring to the Linux kernel, not user-space software that runs on Linux. The Linux kernel is written in C, but uses lots of GCC-specific features and inline assembly to address things that aren't covered by the C standard. Among these, the Linux kernel has its own set of atomic types and memory barriers. It documents them here: https://www.kernel.org/doc/Documentation/memory-barriers.txt https://www.kernel.org/doc/Documentation/memory-barriers.txt So even if Linux is being compiled on a conforming C11 compiler (the Linux kernel is written in C, not C++), it uses its own atomic primitives instead of the ones provided by the language. Hope that helps.