<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:timurrrr@google.com" title="Timur Iskhodzhanov <timurrrr@google.com>"> <span class="fn">Timur Iskhodzhanov</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - VS2013 CL doesn't generate a vtordisp thunk"
   href="http://llvm.org/bugs/show_bug.cgi?id=20477">bug 20477</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>ASSIGNED
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>INVALID
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Summary</td>
           <td>MS ABI: clang generates unnecessary vtordisp adjustment
           </td>
           <td>VS2013 CL doesn't generate a vtordisp thunk
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - VS2013 CL doesn't generate a vtordisp thunk"
   href="http://llvm.org/bugs/show_bug.cgi?id=20477#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - VS2013 CL doesn't generate a vtordisp thunk"
   href="http://llvm.org/bugs/show_bug.cgi?id=20477">bug 20477</a>
              from <span class="vcard"><a class="email" href="mailto:timurrrr@google.com" title="Timur Iskhodzhanov <timurrrr@google.com>"> <span class="fn">Timur Iskhodzhanov</span></a>
</span></b>
        <pre>OK, at first I thought that CL made an "no vtordisp needed" optimization based
on the fact that the B ctor is trivial.

However, this turned out not to be the case -- in fact, it's a miscompile by
CL.
This code built with VS2013 CL:
--------------------------------
  #include <stdio.h>

  struct A {
    virtual A *f() { return this; }
  };

  struct B : virtual A {
    B() {}
    virtual B *f() { return this; }
    int x;
  };

  void foo(B *b) {
    B *bb = b->f();
    printf("bb->x = %d (should be 42)\n", bb->x);
  }

  struct C : B {
    C() {
      x = 42;
      foo(this);
    }
  };

  struct D {
    virtual void g() {};
  };

  struct E : virtual D {};

  struct F : E, C, virtual D, virtual A {};

  int main() {
    F f;
    foo(&f);
  }
--------------------------------
prints out
  bb->x = 17355152 (should be 42)
  bb->x = 42 (should be 42)
[ <a href="https://connect.microsoft.com/VisualStudio/feedbackdetail/view/940530">https://connect.microsoft.com/VisualStudio/feedbackdetail/view/940530</a> ]

Clang did the right thing and the result works correct.</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>