TypeTuple ABI mangling

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 27 00:39:10 PDT 2014


On 27 July 2014 08:22, Iain Buclaw <ibuclaw at gdcproject.org> wrote:
> On 27 July 2014 08:14, Iain Buclaw <ibuclaw at gdcproject.org> wrote:
>> On 27 July 2014 00:20, Iain Buclaw <ibuclaw at gdcproject.org> wrote:
>>> On 26 July 2014 21:06, H. S. Teoh via Digitalmars-d
>>> <digitalmars-d at puremagic.com> wrote:
>>>> On Sat, Jul 26, 2014 at 07:44:47PM +0000, Iain Buclaw via Digitalmars-d wrote:
>>>>> Hi,
>>>>>
>>>>> TypeTuples have a special mangling convention in the compiler.
>>>>>
>>>>> As per the docs (ref: http://dlang.org/abi.html)
>>>>>
>>>>> TypeTuple:
>>>>>     B Number Arguments
>>>>>
>>>>>
>>>>> However after some cursory tests, it seems that the most obvious examples
>>>>> of, passing a tuple via parameters, returning a tuple, declaring a tuple
>>>>> variable, etc... all get lowered before mangling.
>>>>>
>>>>> So at first glance, this mangling convention is redundant.
>>>>>
>>>>> Unless of course someone can post an example which triggers mangling
>>>>> of TypeTuples...
>>>> [...]
>>>>
>>>> Huh, interesting. I tried various wrapping/unwrapping tricks and passing
>>>> things via alias parameters, but none of them triggered TypeTuple
>>>> mangling. Either I missed something obvious, or perhaps this mangling is
>>>> never actually emitted? Not sure.
>>>>
>>>
>>> I've tried something similar using D1 too, and get the same results.
>>>
>>> I'd be willing to do an experiment and remove TypeTuple mangling from
>>> the language by force and see what ICE's.
>>
>> I changed Ttuple = 'B' to Ttuple = '@' and waited for assembly errors to happen.
>>
>> Finally got them when compiling std.outbuffer unittests.
>>
>> Reducing....
>
>
> Ah ha!  D-style native varargs use them!
>
> void printf(...) { }
> void main()
> {
>     printf;    // printf(_arguments_typeinfo);
> }
>
> Here, the _arguments_typeinfo is a TypeInfo_Tuple.
>

Inspecting the resultant mangled identifier itself though, the tuple
part will never get demangled.

_D15TypeInfo_B4iiii6__initZ

Meaning that I'm back at demangling tuple being pointless because it
will never be reached.


More information about the Digitalmars-d mailing list