[PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 6 01:06:46 PDT 2016


majnemer added a comment.

Hmm, I'm not so sure this will work with constexpr:

  #include <stdio.h>
  struct __declspec(dllimport) S {
      virtual void fn() const {printf("%s\n", "hi");}
      constexpr S() = default;
  };
  
  constexpr S s;
  auto &x = s;
  
  int main() {
      x.fn();
  }

Before my change we would reference the imported vftable symbol from the .rdata section which will fail at link time.
IIRC, MSVC will miscompile this example.

Your change, if I understand correctly, will cause us to import the vftable symbol which would cause this example to break again.


http://reviews.llvm.org/D22034





More information about the cfe-commits mailing list