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

Timur Iskhodzhanov <[email protected]> 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 <[email protected]> ---
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to