On 24 March 2016 at 12:29, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote: > On 24 March 2016 at 12:20, Jeffrey Walton <noloader@xxxxxxxxx> wrote: >> On Thu, Mar 24, 2016 at 8:10 AM, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote: >>> On 24 March 2016 at 11:55, Jeffrey Walton wrote: >>>> In the test program below, why does -Wabi-tag trigger a warning with >>>> the std::string when using -std=c++03? >>> >>> "Although the changes were made for C++11 conformance, the choice of >>> ABI to use is independent of the -std option used to compile your >>> code, i.e. for a given GCC build the default value of the >>> _GLIBCXX_USE_CXX11_ABI macro is the same for all dialects. This >>> ensures that the -std does not change the ABI, so that it is >>> straightforward to link C++03 and C++11 code together. " >>> >>> https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html >> >> Thanks. I recall reading that a couple of days ago. I still don't >> quite understand what it means. I'm obviously missing something. >> >> I guess my knowledge gap is due to _GLIBCXX_USE_CXX11_ABI should apply >> to C++11 and above to comply with the newer C++ rules, wrote-on-copy >> strings, etc. I don't understand how it effects C++03 and below since >> the rules that required the change don't apply. > > The new std::string and std::list are also valid implementations for C++03. > > Try reading this bit again: "This ensures that the -std does not > change the ABI, so that it is straightforward to link C++03 and C++11 > code together." To conform to C++11 we needed new string and list implementations, which are incompatible with the old ones. We could have made -std=c++03 use the old ABI by default, and -std=c++11 use the new ABI by default, but then using -std would affect ABI, and you could not link C++03 code to C++11 code. So instead we made the ABI that is used by default independent of the -std option. It is controlled by a macro, which is set when GCC is configured, and the value of the macro is independent of the -std option. I'm open to suggestions for how to word the documentation to make that clearer, but it already says that AFAICT.