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

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 18 17:24:32 PDT 2021


rsmith added a comment.

In D98904#2636109 <https://reviews.llvm.org/D98904#2636109>, @zoecarver wrote:

> I think we'd basically need a condition that says: `is-microsoft && less-than-cxx17 && is-constexpr && is-static-data-member`.

Yes.

Looking back over the history a bit here, https://reviews.llvm.org/D47956 suggests that treating these static constexpr data members as implicitly inline matches the MS behavior. And I don't think I can disprove that: considering https://godbolt.org/z/7z6T3q, it looks like MSVC gets the "don't instantiate the initializer of an inline static data member with the class" rule wrong in general, which (perhaps by chance alone) means that MSVC doesn't have the same accepts-invalid bug that we have, but only because it's being hidden by a rejects-valid bug for the same case!

So. I think the status quo is OK but not great; we accept invalid code, in the name of MSVC compatibility, that MSVC doesn't accept. I don't think following MSVC would be a good thing, as that'd lead to our rejecting valid code (that MSVC also rejects but that we currently accept). If we can split the difference, and eagerly instantiate only in the case where the language rules say the variable is not inline but MSVC says it is inline, that would be an improvement, but it seems awkward as I think we've already lost the relevant information by the point we need to make the decision.


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