[LLVMbugs] [Bug 20477] VS2013 CL doesn't generate a vtordisp thunk

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Aug 7 08:49:00 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20477

Timur Iskhodzhanov <timurrrr at google.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |INVALID
            Summary|MS ABI: clang generates     |VS2013 CL doesn't generate
                   |unnecessary vtordisp        |a vtordisp thunk
                   |adjustment                  |

--- Comment #3 from Timur Iskhodzhanov <timurrrr at google.com> ---
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) 
[ https://connect.microsoft.com/VisualStudio/feedbackdetail/view/940530 ]

Clang did the right thing and the result works correct.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140807/c4ad6f84/attachment.html>


More information about the llvm-bugs mailing list