[Bug c++/53673] Add magic weak symbol to indicate C++ standard setting (C++03, C++11 etc) to help debug ABI problems

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jun 15 17:47:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53673

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-06-15 17:46:51 UTC ---
(In reply to comment #6)
> Technically, you could add it to the top of <stddef.h> or whatever is a
> guaranteed included library header:

libstdc++'s <bits/c++config.h> would be the right place and as part of the std
lib the symbol should probably be named __glibcxx_blah

I think you'd also need an actual definition or nothing will be emitted for the
declaration alone:

#if __GXX_WEAK__
#if __cplusplus == 201103L
extern "C" void __glibcxx_std_cxx11() __attribute__((weak));
extern "C" void __glibcxx_std_cxx11() { }
#else if __cplusplus == 199711L
extern "C" void __glibcxx_std_cxx98() __attribute__((weak));
extern "C" void __glibcxx_std_cxx98() { }
#else
#warning Unknown C++ standard version
#endif
#endif


> No, it's fair enough, I only know that from watching the discussions on ISO and
> I have no idea if it's actually written in the final published standard. It is
> however written in Nicolai Josuttis' updated C++11 "The C++ standard library"
> in the chapter on C++11 core language changes. And if you think it through,
> there has to be in practice ABI breakage in 03 ABIs because no one could have
> anticipated during their design of what 11 would require [1].
> 
> [1]: This may not apply to GCC as it revised its ABI quite recently, and I'm
> sure its designers took into account likely future 11 requirements.

The current G++ ABI is eight years old and (modulo bugs) the same for c++98 and
c++11, see Bug 53646 comment 17

Again, the incompatibilities are in the library not the core language.
Whether that's generally true for other compilers is irrelevant here.



More information about the Gcc-bugs mailing list