The ABI of STL is different between Release- and Debug-mode under MSVC. One category of difference is additional private members in types under Debug mode, to add various run-time checks and metadata. But there are also other categories of differences. (example)
I wouldn't even expect my own types to be ABI-compatible between Release and Debug mode under MSVC, unless I finely controlled the layout with a bunch of #pragma
s (and of course used no STL in my headers). This is because I expect the designers of MSVC make no effort to make Debug- and Release-mode builds ABI compatible, because they've already thoroughly broken compatibility for STL.
I'm surprised to hear your report that this is not also the case under whatever compilers you used under Linux. Among C++ MSVC users like me, the understanding is that half the point of a Debug build is the extra run-time checks and metadata. Maybe you were talking about C binaries, or about C++ binaries with extern "C"
interfaces -- both of which IIRC are more common on Linux than binaries with a C++ ABI? (Even the latter will explode at run-time when mixed with binaries of the other mode, of course, if you are sending STL types over opaque pointers or some other attempted workaround.)
As you are probably aware, you cannot safely link binaries with a C++ ABI produced by different toolchains -- even different versions of the same toolchain -- unless the toolchain vendor explicitly says otherwise. This is because the details of how e.g. a function call works at the level of layout and machine instruction have never been conventionalized for C++ like it has for C. This is why:
- C is the lingua franca of native programming
- Publishers of C++ binaries often give them a C ABI via
extern "C"
.
So then, the reason for my surprise at your question is, if you are looking at a binary with a C++ ABI, typically you:
- already have access to its source code and can easily produce a new build under whatever mode you need (e.g. open-source, or your own binaries); or
- the publisher has published both Release- and Debug-mode versions of its binaries, often for multiple versions of multiple toolchains (e.g. Qt).
The only exceptions I have seen to this have been in the engineering industry -- I remember Siemens published some fancy CAD software, and you were simply required to use the same major-ish version of MSVC they used, which meant you had to upgrade to a newer version of their software when you upgraded to a new version of MSVC, and vice-versa.