[llvm-bugs] [Bug 37915] New: Clang-cl link error virtual dtor of virtual base

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 24 03:37:07 PDT 2018


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

            Bug ID: 37915
           Summary: Clang-cl link error virtual dtor of virtual base
           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 20462
  --> https://bugs.llvm.org/attachment.cgi?id=20462&action=edit
Reproduction

When compiling the same code with Clang-cl (6.0.0) and MSVC (2017), the version
of clang gives a link error while MSVCs does not.

Error: unresolved external symbol "public: virtual __cdecl A::~A(void)"
(??1A@@UEAA at XZ) referenced in function main

Full reproduction described below can also be found in attachment

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

class A
{
  public:
      explicit A() = default;
      virtual ~A() = default;

      A(const A &) = default;
      A(A &&) = default;

      A &operator=(const A &) = default;
      A &operator=(A &&) = default;
};


class EXPORT B : public virtual A
{
   public:
      explicit B();
      virtual ~B();

      B(const B &) = default;
      B(B &&) = default;

      B &operator=(const B &) = default;
      B &operator=(B &&) = default;
};

t.cpp
=====
#define EXPORT_DLL
#include "t.h"
B::B() = default;
B::~B() = default;

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

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

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 m.cpp
move t.obj t.msvc.obj
move m.obj m.msvc.obj
link m.msvc.obj t.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
m.cpp
move t.obj t.clang.obj
move m.obj m.clang.obj
link m.clang.obj t.clang.obj

-- 
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/20180624/b7223125/attachment.html>


More information about the llvm-bugs mailing list