Bug in dmd?

Dukc ajieskola at gmail.com
Tue Jun 14 21:44:48 UTC 2022


On Tuesday, 14 June 2022 at 13:39:12 UTC, Andrey Zherikov wrote:
> I have [pretty simple code in my 
> library](https://github.com/andrey-zherikov/argparse/blob/bug/source/argparse/help.d#L27-L47):
> ```d
> alias CC = SumType!(AA,BB);
> struct AA {}
> struct BB
> {
>     CC[] c;
> }
>
> private void ppp(T, Output)(auto ref Output output, in 
> CommandArguments!T cmd, in Config config)
> {
>     auto cc = CC(AA());  // (1)
> }
> private void printHelp(T, Output)(auto ref Output output, in 
> CommandArguments!T cmd, in Config config)
> {
>     auto cc = CC(AA());  // (2)
> }
>
> void printHelp(T, Output)(auto ref Output output, in Config 
> config)
> {
>     ppp(output, CommandArguments!T(config), config);
>     printHelp(output, CommandArguments!T(config), config);
> }
> ```
>
> [Line (2) 
> produces](https://github.com/andrey-zherikov/argparse/runs/6880350900?check_suite_focus=true#step:5:12) `undefined reference to '_D3std7sumtype__T7SumTypeTS8argparse4help2AATSQtQm2BBZQBl6__dtorMFNaNbNiNfZv'` (it demangles to `pure nothrow @nogc @safe void std.sumtype.SumType!(argparse.help.AA, argparse.help.BB).SumType.__dtor()`)
>
> If I comment line (2) then everything is good (no link errors). 
> Note that there is the same code at (1) which doesn't produce 
> any error. Any idea what's going on?

No idea. The functions seems indeed to be exactly the same, so I 
assume this is a DMD bug. It cannot be a bug in `std.sumtype`, 
since that would trigger in both of the templates.

BTW, thanks for taking the effort to write your question this 
well (demagling, link to your library and all).


More information about the Digitalmars-d-learn mailing list