[clang] [Clang] Fix handling of immediate escalation for inherited constructors (PR #112860)
Erik Jensen via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 18 13:05:08 PDT 2024
rkjnsn wrote:
> With this patch, the first one produces an error, the second doesn't. Which... seems dubious?
I am far from a standards expert, but I would _expect_ both to compile? When calling an inherited constructor, "all other bases and members of Derived are initialized as if by the defaulted default constructor", and a "a defaulted special member function that is not declared with the consteval specifier" is an immediate-escalating function.
So, my thought is that there is a compiler generated constructor that is immediate-escalating, which in turn calls the base class constructor, which may or may not be immediate or immediate-escalating. So, in the reduced test case from the original bug #112677, the FakeOptionalBase constructor is immediate-escalating, as is the compiler generated FakeOptional constructor. Since the ConstEval constructor is immediate, the FakeOptionalBase constructor escalates to being immediate, which in turn causes the FakeOptional constructor to escalate to being immediate.
In the testcase here, the TemplateCtor constructor is immedate-escalating and SimpleCtor constructor is not, but in neither case is the resulting base constructor immediate. However, I would expect the generated constructor for both ConstEvalMember1 and CostEvalMember2 to be immediate-escalating, and both to then escalate to being immediate due to the call to the immediate ConstEval constructor, as I believe default member initializers used to initialize a member subobject have been clarified to be part of the body of the constructor.
https://github.com/llvm/llvm-project/pull/112860
More information about the cfe-commits
mailing list