Neither GCC nor Clang are fully compliant with the C++ standard: a reminder

Dev & Code 18 h agoAdd to bookmarks

Neither GCC nor Clang are fully compliant with the C++ standard: a reminder
Illustration : Momiji Shirogane

A post promoted to the front page of Hacker News reminds us of a truth that many C++ developers prefer to ignore: neither GCC nor Clang implement 100% of the standard. Practical breakdown.

Neither GCC nor Clang are fully compliant with the C++ standard

A post published on sebsite.pw and brought up on Hacker News reminds us of a truth that many C++ devs prefer to ignore: the two largest open-source compilers in the world, GCC (GNU Compiler Collection) and Clang (front-end of the LLVM project), are not fully compliant with the C++ standard. Neither has ever been 100% compliant.

The context

The C++ standard (ISO/IEC 14882) is a tome of over 2,000 pages. Each new version (C++17, C++20, C++23, C++26 in preparation) adds features that implementers must catch up with. In practice, no compiler implements 100% of the standard on time; there are always "feature X partially supported" or "feature Y not implemented" in the compliance tables. The official and up-to-date list is available on cppreference.com (page "Compiler support").

What the post highlights

The author of the post sheds light on a case where both GCC and Clang deviate from the standard: either they accept a program that the standard prohibits, or they reject a program that is perfectly compliant. The exact nature of the bug (frontend, ABI, optimizer) determines the impact - from "incorrect diagnosis" to "silently incorrect code".

For a senior dev, the question is therefore not whether his compiler is buggy - the answer is yes, like any software with 20+ million lines - but where the risk areas are, and which ones he encounters in practice.

What to do when it happens

  1. Replicate on both compilers: if GCC says "error" and Clang says "OK", there is a good chance that one of the two is wrong - useful for isolating the culprit.
  2. Consult Compiler Explorer (godbolt.org) with several versions of GCC/Clang/MSVC in parallel: a few clicks allow you to compare 5 backends at once.
  3. Report on bugzilla.gcc.gnu.org or bugs.llvm.org - the maintainers are responsive and the triage is often done in a few days.
  4. Work around by setting a -std=c++17 or by isolating the problematic construction until it is patched.

To remember

The C++ standard is not the Bible, and compilers are not saints. If your code compiles on GCC 15 but not on Clang 20, there is nothing "miraculous" about it - just two implementations, two interpretations, one standard that is too big. Stay pragmatic, keep godbolt open.

Resources, try it

Article produced by artificial intelligence, reviewed under human editorial control.

Our newsroom
Was this article helpful?

23 people liked this article

Like
K
Kaito KuroganeSenior Dev Writer
Senior polyvalent developer, backend Go + frontend TS, open source contributor.
Share:
LIVERadio Geek Kitsune
Tap to listen, the same sound for everyone
0··
// Schedule
// all stations
// share a track →
Topics
Explore
Information