This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -Wabi is misdesigned (answers the wrong question)
On Fri, Oct 24, 2003 at 01:26:21PM -0600, law@redhat.com wrote:
> That's been a concern as well -- deriving classes from something in our
> headers. The "dump the offsets" idea works great for internal consistency,
> but doesn't help when external code derives classes.
But does it really matter?
Let's ignore libstdc++ ABI differences for the moment. Let's say that
I have a bunch of KDE shared libraries built with compiler A, and I
link it to some of my code, built with compiler B. Let's say that compilers
A and B both agree on the layout of all code that is in the shared libraries,
but my code contains a derived class that the two compilers lay out
differently. Guess what: it doesn't matter! The code still interoperates
correctly. That's because the code compiled by compiler A can only
access the base members of the problematic derived class, or call virtual
functions (which are processed by code compiled by compiler B).
So, the only cases where we care about class layout differences is when
we link code compiled by two compilers, and both of those compilers see
the class. Derived classes that may occur later don't break binary
compatibility.