-
Notifications
You must be signed in to change notification settings - Fork 769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When does the lookup perform for a name used in default member initialization in a class template CWG1396 #4585
Comments
I think we should give default member initializers "when needed" treatment, similar to noexcept-specifiers or default function arguments [temp.inst] p12, p14. However, that feels non-editorial. |
The same is written in https://wg21.link/cwg1396 |
Yes, CWG has agreed to such a proposal. We may change [temp.spec#temp.inst-3] to
Add a new bullet for default member initializer into [temp.inst] as the same manner as [temp.inst#12] has done. |
Since there is an open core issue covering that matter, this shouldn't be handled editorially. |
#5987 is about the default argument rather than default member initialization, this issue is about the name lookup in the default member initialization of a specialization of a class template whose template argument is a class where the instantiation occurs in the non-complete class context. |
This is also an issue that I recently asked on SO(https://stackoverflow.com/questions/67086569/how-does-the-lookup-rule-apply-to-a-name-that-is-used-in-a-default-member-initia). It seems no one can use the current wording to interpret this issue. In simple, the issue is:
The definition of
cc
would cause the implicit specialization forA<B>
, which in turn would cause the name lookup forT::a
.According to the above code, we consider the P is not in the complete context of
B
, hence the membera
ofB
cannot be found at this point. However, major implementations all accept the above example(GCC and Clang). The relevant rule of performing the lookup for a dependent name that appears in template entity is defined as:It's vague here. I infer that the name lookup for
T::a
might be in the definition context of the constructor of the specialization of template classA
. such that could interpret the behavior of these compilers. This is hinted at in the following rule:[class.base.init#9]
However, it's not explicit. I think we should give an explicit rule for when does the name lookup perform for the name in such a case.
The text was updated successfully, but these errors were encountered: