[Issue 20082] Struct with extern destructor that's never called causes link error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 26 05:16:38 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=20082

--- Comment #8 from Rainer Schuetze <r.sagitario at gmx.de> ---
> What's the workaround?

If you can assume that the dtor is supplied as soon as you actually use the
struct, this could work on Windows:

struct S
{
    ~this();
}

void dummyDtor()
{
    // dtor not linked in!
    assert(false);
}

pragma(linkerDirective, "/ALTERNATENAME:" ~ S.__dtor.mangleof ~ "=" ~
dummyDtor.mangleof);

IIRC there is some other way on Posix to get weak linkage.

--


More information about the Digitalmars-d-bugs mailing list