Skip to content

lld-link cannot find std::vector destructor in certain situations #150563

@AlexB8675

Description

@AlexB8675

using latest clang-cl and lld-link (20.1.8) on Windows 11 24H2 with latest build tools 17.14.9, the following code snippet fails to link

#include <vector>

struct Foo {
  int x;
};

struct Bar {
  std::vector<Foo*> a;
  std::vector<Foo*> b;
};

int main() {
  auto one = Foo(1);

  auto* bar = new Bar(
    { &one },
    { &one }
  );

  return 0;
}

With the following terminal commands

D:\LLVM\bin\clang-cl.exe  /nologo -TP  -IC:\Users\Alex\Desktop\Test\build\_deps\mimalloc-src\include /DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -clang:-std=c++23 -MDd -Zi /MDd /showIncludes /FoCMakeFiles\Test.dir\main.cpp.obj /FdCMakeFiles\Test.dir\ -c -- C:\Users\Alex\Desktop\Test\main.cpp
D:\LLVM\bin\lld-link.exe /nologo CMakeFiles\Test.dir\main.cpp.obj  /out:Test.exe /implib:Test.lib /pdb:Test.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib

Workarounds include:

  • Not using C++20's parenthesis aggregate init of bar
  • Adding delete for bar

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions