This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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)


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

Attachment: prepdiff.sh
Description: application/shellscript


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]