<html>
    <head>
      <base href="http://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 --- - [-cxx-abi microsoft] bad vftable for llvm::error_category"
   href="http://llvm.org/bugs/show_bug.cgi?id=17382">17382</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[-cxx-abi microsoft] bad vftable for llvm::error_category
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>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>rnk@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu, timurrrr@google.com
          </td>
        </tr>

        <tr>
          <th>Blocks</th>
          <td>12477
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This manifests as a crash in SupportTests with clang-cl /fallback.

I get a crash with a stack like:
     SupportTests.exe!llvm::error_code::category() Line 767    C++
     SupportTests.exe!llvm::error_category::equivalent(class llvm::error_code
const &,int)    Unknown
<span class="quote">>        SupportTests.exe!llvm::operator==(const llvm::error_code & _x, const llvm::error_condition & _y) Line 797       C++</span >
     SupportTests.exe!llvm::operator==(const llvm::error_condition & _x, const
llvm::error_code & _y) Line 801    C++


The equivalent() method implementation was compiled by clang, and I assume the
vftable came from clang as well, but I have not confirmed this yet.

The call to equivalent() came from MSVC, and it loaded vftable offset 0x10,
which should be the (int, error_condition) overload, but instead we called
clang's implementation of the (error_condition, int) overload.  MSVC seems to
think there should be one more vftable slot.

The vftable looks like this in the debugger:
-        _x    {_val_=22 _cat_=SupportTests.exe!0x03e2f0c8 {...} }    const
llvm::error_code &
        _val_    22    int
-        _cat_    SupportTests.exe!0x03e2f0c8 {...}    const
llvm::error_category *
-        __vfptr    0x03e1bcb0 {SupportTests.exe!const
llvm::_generic_error_category::`vftable'} {0x02815630
{SupportTests.exe!llvm::_generic_error_category::`scalar deleting
destructor'(unsigned int)}, ...}    void * *
        [0]    0x02815630
{SupportTests.exe!llvm::_generic_error_category::`scalar deleting
destructor'(unsigned int)}    void *
        [1]    0x013d6db0
{SupportTests.exe!llvm::_generic_error_category::name(void)const }    void *
        [2]    0x013d6c60
{SupportTests.exe!llvm::error_category::default_error_condition(int)const }   
void *
        [3]    0x013d6ca0
{SupportTests.exe!llvm::error_category::equivalent(int,class
llvm::error_condition const &)const }    void *
        [4]    0x013d6d10
{SupportTests.exe!llvm::error_category::equivalent(class llvm::error_code const
&,int)const }    void *
        [5]    0x013d6dd0
{SupportTests.exe!llvm::_generic_error_category::message(int)const }    void *</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>