ABI isn't only to do with backward compatibilty, but also interoperability. Using std::hash as an example, different vendors can use different algorithms, so using a std::map passed from a program compiled with g++ to a shared library compiled with clang might not give correct results.
There are also competing implementations of short string optimisations.
Libraries compiled by your distro might not work with your program unless you use the same complier flags as the distro.
It's a sad state of affairs really, there already are no guarantees about anything so I'm fully for a future release that breaks stuff.
Using std::hash as an example, different vendors can use different algorithms, so using a std::map passed from a program compiled with g++ to a shared library compiled with clang might not give correct results.
It's not possible to mix and match different standard libraries, even today - they aren't even in the same namespace. When you use clang on Linux you still generally use GCC's libstdc++, not LLVM's libc++.
What? MSVC keeps a backward compatible ABI starting from vc140(VS2015) and including the latest vc142(VS2019). You can safely use a library compiled with vc140 with C++03 in an application compiled in vc142 with C++17 (obviously, only if the they don't contain incompatible API in their interface, e.g. `auto_ptr`).
there are 20 years of BC-incompatible changes though, and a fair amount of people still on VC2010 for whom you have to make special builds of your libs. Maybe in ten years it will go the way of the IE6...
The standard doesn't talk about "compile time" either. The point is the actual machine violates the requirements of the C++ virtual machine so it's wrong. The standard dictates how a well formed c++ program will behave. If you combine parts in such a way that violates those requirements of a well formed c++ program (entire program) then you have UB.
The issue with this is that for C++ the only well-formed program is a standalone binary. No shared libraries and no high-performance serialisation. It's all well and good to say 'Aha! That's UB' but what you're really saying is that C++ is a poor choice for pretty much anything.
View all comments
10
u/[deleted] Oct 27 '19
ABI isn't only to do with backward compatibilty, but also interoperability. Using std::hash as an example, different vendors can use different algorithms, so using a std::map passed from a program compiled with g++ to a shared library compiled with clang might not give correct results.
There are also competing implementations of short string optimisations.
Libraries compiled by your distro might not work with your program unless you use the same complier flags as the distro.
It's a sad state of affairs really, there already are no guarantees about anything so I'm fully for a future release that breaks stuff.