extern(C++) and shared

deadalnix deadalnix at gmail.com
Sun Nov 27 04:54:15 PST 2011


Le 27/11/2011 13:16, Martin Nowak a écrit :
> On Sun, 27 Nov 2011 01:20:35 +0100, deadalnix <deadalnix at gmail.com> wrote:
>
>> alias extern(C++) void* function(void*) EntryPoint
>
> Can you please file a reduced test case as bug
> stating exactly what in the mangling went wrong.
>
> Not sure about the current policy of passing shared data to C++ functions.
> It seems to work on a promise base, then stripping the qualifiers.
>
> martin

module fail;

extern(C++) void foo1(void*);
extern(C++) void bar1(shared void*);

pragma(msg, foo1.mangleof);
pragma(msg, bar1.mangleof); // shared is ignored here, because C++ 
doesn't have shared, this make sense.

extern(C++) void foo2(void function(void*));
extern(C++) void bar2(void function(shared void*));

pragma(msg, foo2.mangleof);
pragma(msg, bar2.mangleof); // shared is ignored here, because C++ 
doesn't have shared, this make sense.

extern(C++) void foo3(void function(void*), void*);
extern(C++) void bar3(void function(shared void*), void*);

pragma(msg, foo3.mangleof);
pragma(msg, bar3.mangleof); // shared generate a different mangling here.

extern(C++) void foo4(void function(void*), shared void*);
extern(C++) void bar4(void function(shared void*), shared void*);

pragma(msg, foo4.mangleof); // Same mangling as bar3.
pragma(msg, bar4.mangleof); // back to correct mangling (the one 
expected by g++).

extern(C++) void foo5(void* function(void*), void*);
extern(C++) void bar5(void* function(shared void*), void*);

pragma(msg, foo5.mangleof);
pragma(msg, bar5.mangleof); // shared generate a different mangling here.

extern(C++) void foo6(void* function(void*), shared void*);
extern(C++) void bar6(void* function(shared void*), shared void*);

pragma(msg, foo6.mangleof); // shared generate a different mangling here.
pragma(msg, bar6.mangleof); // function pointer mangled as in bar5, but 
second parameter get a "0" in the mangling that none of the mangling 
above had.

Give the following output :
_Z4foo1Pv
_Z4bar1Pv
_Z4foo2PFvPvE
_Z4bar2PFvPvE
_Z4foo3PFvPvES_
_Z4bar3PFvPvEPv
_Z4foo4PFvPvEPv
_Z4bar4PFvPvES_
_Z4foo5PFPvS_ES_
_Z4bar5PFPvPvES_
_Z4foo6PFPvS_EPv
_Z4bar6PFPvPvES0_

Comment describe what is inconsistent (or what require something on C++ 
side that I'm not aware of). None is generating any warning. GDC and G++ 
are used here, both in 4.6.2 version (and frontend v2.055, the last 
supported by GDC) on linux amd64.


More information about the Digitalmars-d mailing list