[PATCH] D98904: Instantiate static constexpr data members on MS ABI.

Zoe Carver via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 18 15:56:58 PDT 2021


zoecarver added a comment.

So, as I mentioned in the description of this patch, the reason that these members are treated as definitions is that Clang implicitly marks them as inline when targeting MS. This is sort of interesting a) because it only applies to constexpr vars, and b) because this also happens on all platforms for `std=c++17`. This means that the following program will compile successfully with `std=c++17`:

  template <class T>
  struct GetTypeValue {
    static constexpr const bool value = T::value;
  };
  
  using Invalid = GetTypeValue<int>;

However, if the `constexpr` is removed, it will fail to compile. Conversely, after this patch is applied, that will not happen on Windows (it will fail to compile regardless of the targeted standard or constexprness). I think it would make sense to "fix" this for `std=c++17` as well, but I'm not sure if that's in line with the standard.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98904/new/

https://reviews.llvm.org/D98904



More information about the cfe-commits mailing list