Incompatible C++98 and C++11 assembler code (was: Fix for PR libstdc++/51142 causes incompatibility when mixing C++98 and C++11 code with gcc-4.6.3 and later)
Nicolas Roeser
nicolas.roeser@uni-ulm.de
Fri Sep 21 07:33:00 GMT 2012
On 2012-09-17, 11:14, Paolo Carlini wrote:
> Nicolas Roeser <nicolas.roeser@uni-ulm.de> ha scritto:
>
>> Hello!
>>
>> We found that the fix for PR 51142
>> <URL:http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51142>,
>
> That fix just added an overload, C++11 return type was already different.
Agreed.
>
>> Is linking together several object files compiled with different C++
>> versions not supported?
>
> It isn't, and in any case we can't certainly break C++11 now (neither C++98)
Umm⦠yes. The language standard is OK. The assembler code produced by
g++ is incompatible.
Consider the following scenario:
Alice and Bob are both using g++ from gcc-4.6.3. Alice creates a
library. She distributes distributes libalice.so and alice.h to Bob.
Alice does not know which -std=⦠Bob is using.
This means that Alice has to provide multiple libalice.so versions: at
least one compiled with -std=c++98 and one compiled with -std=c++11.
Or are we missing something here?
The C++ standard works on an abstract machine, as far as we could see
from N3337 (section 1.9), so this isnât a problem there. The way g++
handles calls to functions causes the issue. Preprocessed code is
identical, assembler code marginally differs (stack structure). We used
the attached script for verification. Should this thread be moved to the
gcc mailing list?
I assume that you also cannot be sure that -std=c++11 and -std=gnu++11
(or -std=c++98 and -std=gnu++98) are binary compatible, can you?
--
Nico
-------------- next part --------------
A non-text attachment was scrubbed...
Name: prepdiff.sh
Type: application/x-shellscript
Size: 1044 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20120921/62a3edb4/attachment.bin>
More information about the Libstdc++
mailing list