<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - [Windows] Incorrect name mangling for "vbase destructor"."
   href="https://llvm.org/bugs/show_bug.cgi?id=31931">31931</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Windows] Incorrect name mangling for "vbase destructor".
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.9
          </td>
        </tr>

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

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

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>eric@andante.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=17966" name="attach_17966" title="Testcase which demonstrates the bug.">attachment 17966</a> <a href="attachment.cgi?id=17966&action=edit" title="Testcase which demonstrates the bug.">[details]</a></span>
Testcase which demonstrates the bug.

There are a couple of name mangling bugs in llvm/clang that I am noticing -
they always seem to have to do with "vbase destructors".  The enclosed testcase
demonstrates this.

Clang generates symbol references like such:

  0:0000000 T ??_Dbasic_istream@@UAE@XZ
  0:0000000 T ??_Dbasic_istringstream@@UAE@XZ

The same source, when compiled with visual studio 2013, generates these symbols
in the object file:

   0:0000000 ? ??_Dbasic_istream@@QAEXXZ
   0:0000000 ? ??_Dbasic_istringstream@@QAEXXZ

And you should see that there are slight differences in the mangled names.  The
microsoft demangling tool decodes these as follows:

Undecoration of :- "??_Dbasic_istream@@UAE@XZ"
is :- "public: virtual __thiscall basic_istream::`vbase destructor'(void)"

Undecoration of :- "??_Dbasic_istream@@QAEXXZ"
is :- "public: void __thiscall basic_istream::`vbase destructor'(void)"

The only difference in the names is towards the end.  Clang is using an '@' in
the 3rd from the end, which signifies an unspecified return type.  Visual
studio uses a 'X', which signifies a void return type.  This is generated in

MicrosoftCXXNameMangler::mangleFunctionType()

The second issue is 6th from the end.  Clang is using a 'U', Visual Studio is
using a 'Q'.  The 'U' signifies "virtual".  My guess is that it is redundant to
have this set for a vbase destructor, but I guess the reason is unimportant in
that this is a difference from what Microsoft compilers are generating

This is set in MicrosoftCXXNameMangler::mangleFunctionClass()

It wasn't hard to follow through to see how clang came up with the mangled name
that it did, but it isn't at all obvious to me what the correct fix should be.</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>