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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 25 09:37:44 UTC 2019


Rainer Schuetze <r.sagitario at gmx.de> changed:

           What    |Removed                     |Added
                 CC|                            |r.sagitario at gmx.de
           Hardware|x86_64                      |All
                 OS|Windows                     |All

--- Comment #1 from Rainer Schuetze <r.sagitario at gmx.de> ---
The problem is that the dtor is referenced by the TypeInfo for S and that the
MS linker doesn't eliminate the reference to it before removing unused COMDATs
due to the default /OPT:REF. optlink is more aggressive and works the other way

Even if the MS linker behaved the same, the default for /DEBUG builds is
/OPT:NOREF so the issue would reappear, and more so with debug info generation
(optlink also reports the unresolved symbol in that case).

The online compiler (probably linux) also reports an unresolved symbol, so the
problem is not Windows specific.

For the MS linker, a workaround might be to add a pragma(linkerDirective,
"/ALTERNATENAME:...") to weakly redirect the symbol to a dummy function.


More information about the Digitalmars-d-bugs mailing list