rsmith added a comment. In D98904#2636021 <https://reviews.llvm.org/D98904#2636021>, @zoecarver wrote:
> 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>; (I think you're missing something here to trigger the instantiation of the class, such as `Invalid x;`.) > 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. The above example is valid in C++17 onwards, because in C++17 onwards, static constexpr data members are implicitly inline, and the delayed instantiation behavior here is correct for inline static data members. We'll need to distinguish here between the case where the variable is implicitly inline solely because of the MS ABI rules and the case where the variable is inline because of the actual language rules (where it's declared either `inline` or `constexpr`). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D98904/new/ https://reviews.llvm.org/D98904 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits