<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 - Name mangling different msvc/clang for covariant return type"
   href="https://bugs.llvm.org/show_bug.cgi?id=40138">40138</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Name mangling different msvc/clang for covariant return type
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>7.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>jvapen@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>Created <span class=""><a href="attachment.cgi?id=21267" name="attach_21267" title="Full reproduction">attachment 21267</a> <a href="attachment.cgi?id=21267&action=edit" title="Full reproduction">[details]</a></span>
Full reproduction

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

Both compilers generate the symbol:
?clone@Derived@@EEBAPEAV1@XZ
MSVC generates a second symbol:
?clone@Derived@@QEBAPEAVInterface@@XZ
Clang generates a second symbol:
?clone@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@Derived@@EEBAPEAV1@XZ" t.msvc.sym
grep "?clone@Derived@@QEBAPEAVInterface@@XZ" t.msvc.sym
echo NOT GENERATED
grep "?clone@Derived@@AEBAPEAVInterface@@XZ" t.msvc.sym
echo CLANG
grep "?clone@Derived@@EEBAPEAV1@XZ" t.clang.sym
grep "?clone@Derived@@QEBAPEAVInterface@@XZ" t.clang.sym
echo NOT GENERATED
grep "?clone@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};
  }
};</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>