https://bugs.llvm.org/show_bug.cgi?id=51414
Bug ID: 51414
Summary: Exporting nested classes doesn't compile and link with
Clang on Windows
Product: clang
Version: 12.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: peterghos...@gmail.com
CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
neeil...@live.com, richard-l...@metafoo.co.uk
The following code won't compile and link using `clang-cl /std:c++17 test.cpp`.
#include <optional>
#include <vector>
#include <string>
#include <iostream>
#define EXPORT_OUTER __declspec(dllexport)
#define EXPORT_INNER __declspec(dllexport)
class EXPORT_OUTER A
{
public:
class EXPORT_INNER B
{
public:
B(
const std::optional<std::vector<std::string>> &opt =
std::nullopt)
{
}
};
};
int main()
{
auto b = A::B();
return 0;
}
Error:
test-e1dae6.obj: error LNK2019: Unresolved external symbol "public: __cdecl
std::optional<class std::vector<class std::basic_string<char,struct
std::char_traits<char>,class std:: allocator<char> >,class std::allocator<class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char>>>> >::~optional<class std:: vector<class
std::basic_string<char,struct std::char_traits<char>,class std::allocator<char>
>,class std::allocator<class std::basic_string<char,struct
std::char_traits<char >,class std::allocator<char>>>> >(void)"
(??1?$optional@V?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator
@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@
std@@QEAA@XZ), the symbol is referenced in the function main
test.exe: fatal error LNK1120: 1 unresolved external command
clang-cl: error: linker command failed with exit code 1120 (use -v to see
invocation)
However, the same code compiles and links if
1. using cl.exe from MSVC
2. using `#define EXPORT_INNER` instead
3. removing the default value of `opt` in the ctor of the class B and passing
in `std::nullopt` explicitly
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs