diff --git a/llvm/include/llvm/ADT/Any.h b/llvm/include/llvm/ADT/Any.h --- a/llvm/include/llvm/ADT/Any.h +++ b/llvm/include/llvm/ADT/Any.h @@ -31,9 +31,9 @@ // identifier for the type `T`. It is explicitly marked with default // visibility so that when `-fvisibility=hidden` is used, the loader still // merges duplicate definitions across DSO boundaries. - template struct TypeId { - static const char Id; - }; + // We also cannot mark it as `const`, otherwise msvc merges all definitions + // when lto is enabled, making any comparison return true. + template struct TypeId { static char Id; }; struct StorageBase { virtual ~StorageBase() = default; @@ -117,7 +117,7 @@ std::unique_ptr Storage; }; -template const char Any::TypeId::Id = 0; +template char Any::TypeId::Id = 0; template bool any_isa(const Any &Value) { if (!Value.Storage)