Yes it is allowed, modulo bugs in GCC.

The compiler

GCC follows the Itanium ABI, which is actually platform-independent, despite the name. Here is the Itanium ABI mission statement:

we want users to be able to build relocatable objects with different compilers and link them together, and if possible even to ship common DSOs.

Note there are no separate ABI specifications for separate versions of the C++ standard. There is one specification that works for them all.

The library

Here is the mission statement of libstdc++ as far as versioning is concerned

Extending existing, stable ABIs. Versioning gives subsequent releases of library binaries the ability to add new symbols and add functionality, all the while retaining compatibility with the previous releases in the series. Thus, program binaries linked with the initial release of a library binary will still run correctly if the library binary is replaced by carefully-managed subsequent library binaries. This is called forward compatibility.

The library supports not one, but two different ABIs. There was a change in the C++11 standard that necessitated an ABI split. However, as the documentation points out, the choice of ABI to use is independent of the -std option used to compile your code. This is ancient history however. You are going to use the new C++11-compatible ABI, which is the default, about 100% of the time, unless you need to maintain an old piece of software built with pre-C++11-compatible ABI.

The real life

The open source ecosystem has zillions of C++ libraries that are used in all kind of products. No one coordinates -std option between maintainers of different libraries. Everybody upstream uses what they want/need, and downstream the libraries are built with whatever options are there, and linked together with no problem. It all just works.

I personally run Gentoo, which is a rolling release distro. I fetch whatever stable release of a software component is available directly from that library's GitHub or whatever it is stored, and compile with whatever compiler version I currently have. I can recompile any library using any compiler version at any time. The system still works just fine. Without this kind of cross-standard, cross-version compatibility, a rolling release would never ever have a chance to work.

Conclusion

Is it 100% safe? You decide. There are compiler bugs in this area (you have found one) and sometimes people get biten by them. Then again, there are compiler bugs in all areas, but people still use compilers.

Answer from n. m. could be an AI on Stack Overflow
🌐
GNU
gcc.gnu.org › projects › cxx-status.html
C++ Standards Support in GCC - GNU Project
May 4, 2026 - Or, to enable GNU extensions in addition to C++23 features, add -std=gnu++23. Important: Because the ISO C++23 standard is very recent, GCC's support is experimental. GCC has almost full support for the previous revision of the C++ standard, which was published in 2020. The status of C++20 ...
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_developer_toolset › 11 › html › user_guide › chap-gcc
Chapter 2. GNU Compiler Collection (GCC) | User Guide | Red Hat Developer Toolset | 11 | Red Hat Documentation
A compiler in C++11, C++14, or C++17 mode is only guaranteed to be compatible with another compiler in those same modes if they are from the same release series. ... The GCC compiler in Red Hat Developer Toolset 10.x can build code using C++20 but this capability is experimental and not supported ...
Discussions

c++ - Is mixing C++11 and C++20 allowed with GCC? - Stack Overflow
I declare a struct in a header file. I use this struct in two compilation units. One is compiled with -std=c++11 and the other with -std=c++20. The sizeof my struct is different in the two compilat... More on stackoverflow.com
🌐 stackoverflow.com
Which c++ standard to adopt for new projects, c++11 to c++20?
Pick the latest standard supported by all of the compilers you care about. You might only care about your own computer's compiler or you may want to support many compilers from years past or something in between. Chances are all of the compilers you care about are new enough to support C++17 so I would not pick anything older than that. It's possible you can use C++20 since the latest releases of all major compilers have very good C++20 support. More on reddit.com
🌐 r/cpp
66
26
August 31, 2024
When is stable GCC c++20 support expected?
Switched our codebase at work yesterday to 10.2 after playing around with it on some personal projects. Sure, it's incomplete, but I haven't stumbled on any terrible bugs, unit tests compile without an ICE, and now I don't have to write a single line of sfinae (concepts) or comparison operators (<=> = default) ever again. And then there are coroutines (as of boost 1.74.0/asio 1.17.0 usable with asio::awaitable), std::span, std::ranges... I'd say it's too good not to switch. The major thing missing are modules. More on reddit.com
🌐 r/cpp
36
62
August 27, 2020
Why major compilers likw GCC and Clang still do not support C++20 modules ??
Both Clang and GCC are actually moving pretty quickly in modules development, lately. Every time I look at their recent commits, I see some improvements there. Chuanqi Xu (a developer who's played a pivotal role in Clang and CMake modules support) has recently shifted to working on another new ABI for Clang's named-modules that should wind up being much smaller and potentially even faster. More on reddit.com
🌐 r/cpp
92
129
May 5, 2024
🌐
GNU
gcc.gnu.org › onlinedocs › gcc › Standards.html
Standards (Using the GNU Compiler Collection (GCC))
You may also select an extended version of the C++ language explicitly with -std=gnu++98 (for C++98 with GNU extensions), or -std=gnu++11 (for C++11 with GNU extensions), or -std=gnu++14 (for C++14 with GNU extensions), or -std=gnu++17 (for C++17 with GNU extensions), or -std=gnu++20 (for C++20 with GNU extensions), or -std=gnu++23 (for C++23 with GNU extensions). The default, if no C++ language dialect options are given, is -std=gnu++20. GCC supports “traditional” Objective-C (also known as “Objective-C 1.0”) and contains support for the Objective-C exception and synchronization syntax.
🌐
Phoronix
phoronix.com › news › GCC-11-Flips-On-CPP20-Coroutine
GCC 11 Enables Co-Routines Support In C++20 Mode - Phoronix
May 16, 2020 - The recently released GCC 10 compiler ... being enabled by default when running in C++20 mode (std=c++20). Thus for next year's GCC 11 release will be working coroutines functionality when C++20 is enabled....
Top answer
1 of 2
4

Yes it is allowed, modulo bugs in GCC.

The compiler

GCC follows the Itanium ABI, which is actually platform-independent, despite the name. Here is the Itanium ABI mission statement:

we want users to be able to build relocatable objects with different compilers and link them together, and if possible even to ship common DSOs.

Note there are no separate ABI specifications for separate versions of the C++ standard. There is one specification that works for them all.

The library

Here is the mission statement of libstdc++ as far as versioning is concerned

Extending existing, stable ABIs. Versioning gives subsequent releases of library binaries the ability to add new symbols and add functionality, all the while retaining compatibility with the previous releases in the series. Thus, program binaries linked with the initial release of a library binary will still run correctly if the library binary is replaced by carefully-managed subsequent library binaries. This is called forward compatibility.

The library supports not one, but two different ABIs. There was a change in the C++11 standard that necessitated an ABI split. However, as the documentation points out, the choice of ABI to use is independent of the -std option used to compile your code. This is ancient history however. You are going to use the new C++11-compatible ABI, which is the default, about 100% of the time, unless you need to maintain an old piece of software built with pre-C++11-compatible ABI.

The real life

The open source ecosystem has zillions of C++ libraries that are used in all kind of products. No one coordinates -std option between maintainers of different libraries. Everybody upstream uses what they want/need, and downstream the libraries are built with whatever options are there, and linked together with no problem. It all just works.

I personally run Gentoo, which is a rolling release distro. I fetch whatever stable release of a software component is available directly from that library's GitHub or whatever it is stored, and compile with whatever compiler version I currently have. I can recompile any library using any compiler version at any time. The system still works just fine. Without this kind of cross-standard, cross-version compatibility, a rolling release would never ever have a chance to work.

Conclusion

Is it 100% safe? You decide. There are compiler bugs in this area (you have found one) and sometimes people get biten by them. Then again, there are compiler bugs in all areas, but people still use compilers.

2 of 2
2

The issue can be reproduced with this small code:

#include <iostream>

struct A { 
    double d{0.0};
    int i1{1};
};

struct C : public A { 
    int i2{2};
};

int main(int argc, char* argv[]) {
    C c;
    std::cout << "sizeof(C) = " << sizeof(C) << std::endl;
              << "&i2 - &i1 = " << (((char*) &c.i2) - ((char*) &c.i1))
              << std::endl;
    return 0;
}

When compiled with G++ in C++11 mode or when compiled with clang (any mode), the result is:

sizeof(C) = 16
&i2 - &i1 = 4

When compiled with G++ in C++14 (or later) mode, the result is:

sizeof(C) = 24
&i2 - &i1 = 8

Apparently, G++ since C++14 refuses to overlay fields of struct C into struct A. Note that sizeof(A) is 16 with all compilers, which is required, so that arrays of objects of type A are well-aligned. So there is an implicit 4-byte padidng after i1. clang (all versions) and G++ (until C++11) recycle that padding, when another int is added through inheritance, G++ (later versions) does not.

This is clearly a binary compatibility breaking change between C++11 and C++14 mode in G++, that can manifest itself in many places of custom code, so linking mixed-compiled code is very dangerous, if the oldest version used is C++11.

Actually, the G++ team seems to have acknowledged this as a bug and fixed it for G++12 and later versions, but has not backported it to older versions of the compiler, so this issue is still present in G++11, which is for example the default compiler in Ubuntu 22.04 LTS. Here a link to the GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103681 Thanks to https://stackoverflow.com/users/5293624/kjpus for reporting this link.

As can be easily verified on Godbolt, the bug is present in G++ version 11.4, but fixed from version 12.1 on: https://godbolt.org/z/chnss5bs3

🌐
SUSE
documentation.suse.com › sbp › devel-tools › pdf › SBP-GCC-11_en.pdf pdf
Advanced Optimization and New Capabilities of GCC 11
Enterprise (SLE) Development Tools Module. GCC 11 comes with many new features, such as · implementing parts of the most recent versions of specifications of various languages (especially · C2X, C++17, C++20) and their extensions (OpenMP, OpenACC), supporting new capabilities of a
Find elsewhere
🌐
Wikipedia
en.wikipedia.org › wiki › C++20
C++20 - Wikipedia
1 month ago - C++20 is a version of the ISO/IEC 14882 standard for the C++ programming language. C++20 replaced the prior version of the C++ standard, called C++17, and was later replaced by C++23. The standard was technically finalized by WG21 at the meeting in Prague in February 2020, had its final draft ...
🌐
Red Hat
developers.redhat.com › blog › 2020 › 09 › 24 › new-c-features-in-gcc-10
New C++ features in GCC 10 | Red Hat Developer
February 5, 2024 - In GCC 11, we plan to finish up the remaining C++20 features. For progress so far, see the C++2a Language Features table on the C++ Standards Support in GCC page. GCC 11 will also switch the default dialect to C++17 (it has already happened).
🌐
Codeforces
codeforces.com › blog › entry › 96040
C++20 Is Released - Codeforces
Please, welcome c++20 support on Codeforces. Yes, it is 64-bit. Thanks to Brecht Sanders: I used his distribution GCC-11.2.0-64 from https://winlibs.com/.
🌐
GNU
gcc.gnu.org › gcc-11 › changes.html
GCC 11 Release Series — Changes, New Features, and Fixes - GNU Project
GCOV data file format outputs smaller files by representing zero counters in a more compact way. GCC 11 adds support for non-rectangular loop nests in OpenMP constructs and the allocator routines of OpenMP 5.0, including initial allocate clause support in C/C++. The OMP_TARGET_OFFLOAD environment ...
🌐
GNU
gcc.gnu.org › gcc-11
GCC 11 Release Series - GNU Project
July 19, 2024 - The GCC developers are pleased to announce the release of GCC 11.5. This release is a bug-fix release, containing fixes for regressions in GCC 11.4 relative to previous releases of GCC.
🌐
Reddit
reddit.com › r/cpp › why major compilers likw gcc and clang still do not support c++20 modules ??
r/cpp on Reddit: Why major compilers likw GCC and Clang still do not support C++20 modules ??
May 5, 2024 -

It is 2024 and my favorite compilers (gcc and clang) still do not support modules completely !!

We already have C++23 and some new features for C++26, but still missed C++ modules ...

Maybe committee should postpone standardization ?!

Top answer
1 of 22
114
Maybe committee should postpone standardization ?! What on Earth would that accomplish? The only reason the compilers are (or have been) working on C++ modules is because it is standardized. If it wasn't there would be essentially no motivation to work on it at all. C++ modules are forcing compiler engineers to rethink the way they approach so many different aspects of compilation. It's not as simple as "it's done" either, there will need to be bake time necessary for implementations to shake out all of the bugs and performance concerns. If I'm taking MSVC as an example, PCH has been a technology in the compiler for over 30 years at this point and the compiler team still gets PCH-specific bugs and PCH is an order of magnitude simpler than C++ modules because if its restrictions around when the user is forced to include it. Keep trying C++ modules with each compiler update, file bugs, and identify workarounds. This is the only real way the implementers can move forward with making the implementation more robust and usable. Better yet, contribute to your favorite open source compiler implementation and help make it more usable for everyone.
2 of 22
64
Both Clang and GCC are actually moving pretty quickly in modules development, lately. Every time I look at their recent commits, I see some improvements there. Chuanqi Xu (a developer who's played a pivotal role in Clang and CMake modules support) has recently shifted to working on another new ABI for Clang's named-modules that should wind up being much smaller and potentially even faster.
🌐
GitHub
github.com › mesonbuild › meson › issues › 12291
meson incorrectly thinks that gcc-11 doesn't support `-std=c++23` · Issue #12291 · mesonbuild/meson
September 26, 2023 - Possible choices are (as string): "none", "c++98", "c++03", "c++11", "c++14", "c++17", "c++1z", "c++2a", "c++20", "gnu++03", "gnu++11", "gnu++14", "gnu++17", "gnu++1z", "gnu++2a", "gnu++20". ... project('bali-phy', ['cpp','c'], version: '4.0-beta7-preview', default_options : [ 'cpp_std=c++23', 'warning_level=3', 'buildtype=release', 'b_ndebug=if-release' ], meson_version: '>= 1.1', license: 'GPLv2') Expected behavior I have gcc-11 version 11.4.0, and gcc-11 -std=c++23 test.cc works fine.
Author   mesonbuild
🌐
cppreference.com
en.cppreference.com › cpp › compiler_support › 20
Compiler support for C++20 - cppreference.com
February 27, 2024 - std::bit_ceil(), std::bit_floor(), std::bit_width(), std::has_single_bit() (FTM)* · rotl(), rotr(), countl_zero(), countl_one(), countr_zero(), countr_one(), popcount() (FTM)*
🌐
GNU
gcc.gnu.org › releases.html
GCC Releases - GNU Project
April 30, 2026 - GCC releases may be downloaded from our mirror sites. Important: these are source releases, so will be of little use if you do not already have a C++ compiler installed. As one option, there are pre-compiled binaries.