<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 --- - [ms] virtual member pointer call gets miscompiled" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23878&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=Uos-gcQxGGQ9sh0N9egQfo4DwC2Xav8KMVSqjmL3af8&s=RXFFbBOy7Gn7cJgwzL5nPuufsEJiH-005e_JpogMDt0&e=">23878</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[ms] virtual member pointer call gets miscompiled
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nicolasweber@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider:

C:\src\chrome\src\out\Debug>type repro.cc
struct Channel { virtual void Connect() = 0; };

struct SupportsAttachmentBrokering { virtual void GetAttachmentBroker() = 0; };
struct ChannelReader : virtual public SupportsAttachmentBrokering {
  void GetAttachmentBroker() override {}
};

struct ChannelWin : public Channel, public ChannelReader {
  void Connect() override {
    void (ChannelWin::*ptr)() = &ChannelWin::OnIOCompleted;
    (this->*ptr)();  // crashes
  }
  virtual void OnIOCompleted() {}
};

int main() {
  ChannelWin channel;
  channel.Connect();
}


This program runs fine when build with cl.exe, but crashes when built with
clang-cl.exe:

C:\src\chrome\src\out\Debug>cl repro.cc /Feasdf && asdf
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

repro.cc
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:asdf.exe
repro.obj

C:\src\chrome\src\out\Debug>"..\..\third_party/llvm-build/Release+Asserts/bin/clang-cl"
-m32 repro.cc /Feasdf.exe && asdf

# ^ This makes a "asdf.ese has stopped working" dialog appear</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>