[llvm-bugs] [Bug 38354] New: Clang-cl generates more code, in this case the Dtor. Resulting in link errors

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jul 29 09:02:52 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38354

            Bug ID: 38354
           Summary: Clang-cl generates more code, in this case the Dtor.
                    Resulting in link errors
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jvapen at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20614
  --> https://bugs.llvm.org/attachment.cgi?id=20614&action=edit
Full reproduction

I've encountered this on both Clang-cl 6.0.0 as trunk (7.0.0) rev336178.
This is causing several (obscure) link errors which can be resolved by making
the Dtor explicit.

Resulting error, not given when compiled with CL:
error LNK2019: unresolved external symbol "public: __cdecl
A<int>::~A<int>(void)" (??1?$A at H@@QEAA at XZ) referenced in function "void __cdecl
f(void)" (?f@@YAXXZ)

Content of the files used, packages in attachment:

Run.bat
-------
cl.exe /nologo /c /GR /EHsc /fp:precise /FS /std:c++17 /diagnostics:caret /O2
/I. /MDd /Zc:forScope /bigobj /Zc:wchar_t t.cpp
cl.exe /nologo /c /GR /EHsc /fp:precise /FS /std:c++17 /diagnostics:caret /O2
/I. /MDd /Zc:forScope /bigobj /Zc:wchar_t u.cpp
cl.exe /nologo /c /GR /EHsc /fp:precise /FS /std:c++17 /diagnostics:caret /O2
/I. /MDd /Zc:forScope /bigobj /Zc:wchar_t m.cpp
move t.obj t.msvc.obj
move u.obj u.msvc.obj
move m.obj m.msvc.obj
link m.msvc.obj t.msvc.obj u.msvc.obj

clang-cl.exe -fms-compatibility-version=19.11 /DBOOST_USE_WINDOWS_H -w
-Wno-unused-command-line-argument  /nologo /c /GR /EHsc /fp:precise /FS
/std:c++17 /diagnostics:caret /O2 /I. /MDd /Zc:forScope /bigobj /Zc:wchar_t
t.cpp
clang-cl.exe -fms-compatibility-version=19.11 /DBOOST_USE_WINDOWS_H -w
-Wno-unused-command-line-argument  /nologo /c /GR /EHsc /fp:precise /FS
/std:c++17 /diagnostics:caret /O2 /I. /MDd /Zc:forScope /bigobj /Zc:wchar_t
u.cpp
clang-cl.exe -fms-compatibility-version=19.11 /DBOOST_USE_WINDOWS_H -w
-Wno-unused-command-line-argument  /nologo /c /GR /EHsc /fp:precise /FS
/std:c++17 /diagnostics:caret /O2 /I. /MDd /Zc:forScope /bigobj /Zc:wchar_t
m.cpp
move t.obj t.clang.obj
move u.obj u.clang.obj
move m.obj m.clang.obj
link m.clang.obj t.clang.obj u.clang.obj

t.h
---
#pragma warning(disable : 4275)
#pragma warning(disable : 4435)
#ifdef EXPORT_DLL
#define EXPORT __declspec(dllexport)
#else
#define EXPORT __declspec(dllimport)
#endif

template <class T>
class A
{
  public:
      explicit A();
      ~A();
  private:
      T t;
};


class EXPORT B
{
   public:
      explicit B();

      A<int> a;
};

t.cpp
-----
#define EXPORT_DLL
#include "t.h"

template <class T>
A<T>::A() : t{} {}
template <class T>
A<T>::~A() {}

B::B(){}

u.cpp
-----
#define EXPORT_DLL
#include "t.h"

void f()
{
   B b{};
}

m.cpp
-----
#include "t.h"

int main(int, char**)
{ 
   B{};
   return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180729/f27da1cb/attachment.html>


More information about the llvm-bugs mailing list