[llvm-bugs] [Bug 40138] New: Name mangling different msvc/clang for covariant return type

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Dec 22 07:17:44 PST 2018


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

            Bug ID: 40138
           Summary: Name mangling different msvc/clang for covariant
                    return type
           Product: clang
           Version: 7.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: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

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

Incorrect mangling of the return type, causes build created via clang to load
extra DLLs.

Both compilers generate the symbol:
?clone at Derived@@EEBAPEAV1 at XZ
MSVC generates a second symbol:
?clone at Derived@@QEBAPEAVInterface@@XZ
Clang generates a second symbol:
?clone at Derived@@AEBAPEAVInterface@@XZ

(See @@AE instead of @@QE)


RUN.BAT
------
cl.exe /nologo /c /EHsc /fp:precise /FS /std:c++17   /MDd  /bigobj     t.cpp
move t.obj t.msvc.obj

C:\DevStudio\LLVM_7_0_0\bin\clang-cl.exe /nologo /c /EHsc /fp:precise /FS
/std:c++17 -fms-compatibility-version=19.11  /MDd  /bigobj     t.cpp
move t.obj t.clang.obj

dumpbin /SYMBOLS t.msvc.obj | grep "External" >t.msvc.sym
dumpbin /SYMBOLS t.clang.obj | grep "External" >t.clang.sym

echo MSVC
grep "?clone at Derived@@EEBAPEAV1 at XZ" t.msvc.sym
grep "?clone at Derived@@QEBAPEAVInterface@@XZ" t.msvc.sym
echo NOT GENERATED
grep "?clone at Derived@@AEBAPEAVInterface@@XZ" t.msvc.sym
echo CLANG
grep "?clone at Derived@@EEBAPEAV1 at XZ" t.clang.sym
grep "?clone at Derived@@QEBAPEAVInterface@@XZ" t.clang.sym
echo NOT GENERATED
grep "?clone at Derived@@AEBAPEAVInterface@@XZ" t.clang.sym

t.cpp
-----
class Interface {
public:
  virtual ~Interface() = default;
  virtual Interface *clone() const;
};
class __declspec(dllexport) A {
public:
  explicit A();
  virtual ~A();
};
class __declspec(dllexport) B : public A,
                                               public Interface {
public:
  virtual ~B();
};
class __declspec(dllexport) Derived : public B {
public:
  explicit Derived();

private:
  virtual Derived *clone() const {
    return new Derived{*this};
  }
};

-- 
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/20181222/93c97d83/attachment.html>


More information about the llvm-bugs mailing list