<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Exporting nested classes doesn't compile and link with Clang on Windows"
   href="https://bugs.llvm.org/show_bug.cgi?id=51414">51414</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Exporting nested classes doesn't compile and link with Clang on Windows
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>12.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>peterghost86@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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>
<span class="quote">>,class std::allocator<class std::basic_string<char,struct</span >
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</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>