September 29, 2020 [Issue 21283] New: [C++] Wrong mangling for ref of parameter pack | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21283 Issue ID: 21283 Summary: [C++] Wrong mangling for ref of parameter pack Product: D Version: D2 Hardware: All OS: Linux Status: NEW Keywords: C++, industry Severity: major Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: pro.mathias.lang@gmail.com C++ code: ``` template<typename T, typename ...Args> void make_shared_poc (Args&... args) {} template void make_shared_poc<int, int, int>(int&, int&); ``` Compiled with `g++ -std=c++11 test.cpp` gives: ``` $ nm test.o 0000000000000000 T __Z15make_shared_pocIiJiiEEvDpRT0_ ``` Now the equivalent D code: ``` extern(C++) void make_shared_poc (T, Args...) (ref Args args); void foobar() { int a, b; make_shared_poc!(int, int, int)(a, b); } ``` Compiled with `dmd -extern-std=c++11 -c test.d` (DMD v2.094.0): ``` U __Z15make_shared_pocIiJiiEEvRDpT0_ ``` Notice that in the C++ code, `R` comes after `Dq` (ref is part of the type), while in the D code, `R` comes before. See https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.function-type : > When a function parameter is a C++11 function parameter pack, its type is mangled with Dp <type>, i.e., its type is a pack expansion: > > <type> ::= Dp <type> # pack expansion (C++11) -- |
Copyright © 1999-2021 by the D Language Foundation