D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21283 - [C++] Wrong mangling for ref of parameter pack
Summary: [C++] Wrong mangling for ref of parameter pack
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Linux
: P1 major
Assignee: No Owner
URL:
Keywords: C++, industry, pull
Depends on:
Blocks:
 
Reported: 2020-09-29 06:15 UTC by Mathias LANG
Modified: 2020-11-16 00:10 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Mathias LANG 2020-09-29 06:15:42 UTC
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)
Comment 1 Dlang Bot 2020-10-05 08:09:27 UTC
@BorisCarvajal updated dlang/dmd pull request #11822 "Fix Issue 21283 - [C++] Wrong mangling for ref of parameter pack" fixing this issue:

- Fix Issue 21283 - [C++] Wrong mangling for ref of parameter pack

https://github.com/dlang/dmd/pull/11822
Comment 2 Dlang Bot 2020-10-05 09:11:15 UTC
dlang/dmd pull request #11822 "Fix Issue 21283 - [C++] Wrong mangling for ref of parameter pack" was merged into stable:

- 6b451bc94690a32c96e897020d44029f7f803f7f by Boris Carvajal:
  Fix Issue 21283 - [C++] Wrong mangling for ref of parameter pack

https://github.com/dlang/dmd/pull/11822
Comment 3 Dlang Bot 2020-10-18 03:23:22 UTC
dlang/dmd pull request #11845 "merge stable" was merged into master:

- b6d97dcfe359956047e6fab59d24403b1589d086 by Boris Carvajal:
  Fix Issue 21283 - [C++] Wrong mangling for ref of parameter pack

https://github.com/dlang/dmd/pull/11845
Comment 4 Dlang Bot 2020-11-16 00:10:07 UTC
dlang/dmd pull request #11961 "merge stable" was merged into master:

- 6f8b9bf516e2deb6b09653d949e34594c7cf7f7a by Boris Carvajal:
  Fix Issue 21283 - [C++] Wrong mangling for ref of parameter pack

https://github.com/dlang/dmd/pull/11961