Why GCC and Clang Defy Standard C++ Rules on Function Linkage
Neither GCC nor Clang are compliant with standard C++
I discovered that GCC and Clang ignore the C++ standard's rule that function types with different language linkages must be distinct. This oversight causes type mismatches and compilation errors where none should exist. I argue the standard is flawed, not the compilers, since changing their behavior would break the ABI while C and C++ calling conventions are identical on most platforms.
"IMO the blame here doesn't lie on GCC or Clang; it lies on the standard."
HN discussion
- On embedded systems, using C++ effectively requires relying on non-conformant GCC and Clang extensions for exceptions and RTTI, making the resulting codebase functionally distinct from standard C++.
- While the article blames GCC and Clang for defying C++ linkage rules, some argue the fault lies with the standard itself for failing to define these behaviors as implementation-defined.
- Breaking source code compatibility to fix non-conformant behavior is often a more significant risk for developers than breaking binary compatibility (ABI).
- CUDA and HIP are fundamentally C++ language extensions rather than pure C APIs, requiring specific compiler support like nvcc or Clang to handle GPU kernel syntax and compilation.
- Modern systems programming languages are increasingly defining behavior that C leaves undefined to prevent bugs from aggressive backend optimizations, offering a safer alternative for students despite potential performance trade-offs.