-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!
Description
Describe the bug
std::any doesn't link when exceptions are disabled
The issue occurs regardless of /EH options; _HAS_EXCEPTIONS=0 matters here.
The issue occurs with /MD or /MDd, not with /MT or /MTd.
Command-line test case
D:\Temp2>type repro.cpp
#include <any>
int main() {
return std::any_cast<int>(std::any{});
}
D:\Temp2>cl /D_HAS_EXCEPTIONS=0 /MD /std:c++17 repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.27.29009.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
repro.cpp
Microsoft (R) Incremental Linker Version 14.27.29009.1
Copyright (C) Microsoft Corporation. All rights reserved.
/out:repro.exe
repro.obj
repro.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::bad_cast::bad_cast(char const *)" (__imp_??0bad_cast@std@@QAE@PBD@Z) referenced in function "public: __thiscall std::bad_any_cast::bad_any_cast(void)" (??0bad_any_cast@std@@QAE@XZ)
repro.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall std::bad_cast::~bad_cast(void)" (__imp_??1bad_cast@std@@UAE@XZ) referenced in function "public: virtual __thiscall std::bad_any_cast::~bad_any_cast(void)" (??1bad_any_cast@std@@UAE@XZ)
repro.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall std::bad_cast::_Doraise(void)const " (?_Doraise@bad_cast@std@@MBEXXZ)
repro.exe : fatal error LNK1120: 3 unresolved externals
Expected behavior
The program should link.
STL version
Microsoft Visual Studio Professional 2019 Preview
Version 16.7.0 Preview 3.1
Additional context
_HAS_EXCEPTIONS=0 is unsupported, see #202 (comment)
This item is also tracked on Developer Community as DevCom-376072 and by Microsoft-internal VSO-725649 / AB#725649.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!