Skip to content

<vector>: change of behavior on linkage requirement with unused dllimported symbols in MSVC 19.29 and onwards #2476

Description

C:\Temp>type meow.cpp
#include <vector>

struct __declspec(dllimport) Cat {
    virtual ~Cat();
};

struct Dog {
    std::vector<Cat> v;

    Dog() { v.emplace_back(); }
};

int main() { }
C:\Temp>cl /EHsc /nologo /W4 /std:c++17 meow.cpp
meow.cpp

C:\Temp>cl /EHsc /nologo /W4 /std:c++20 meow.cpp
meow.cpp
meow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl Cat::~Cat(void)" (__imp_??1Cat@@UEAA@XZ) referenced in function "public: virtual void * __cdecl Cat::`scalar deleting destructor'(unsigned int)" (??_GCat@@UEAAPEAXI@Z)
meow.exe : fatal error LNK1120: 1 unresolved externals

Cameron DaCamara (@cdacamar) believes this was regressed by #1546. I don't know enough about dllimport and "scalar deleting destructors" to immediately diagnose this - it may be by design (I know that C++20 constexpr vector required a bunch of our logic to change) or it may be unintentional/avoidable.

Originally reported as DevCom-1635853 and internal VSO-1461416 / AB#1461416 .

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompilerCompiler work involvedresolvedSuccessfully resolved without a commit

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions