-
Notifications
You must be signed in to change notification settings - Fork 7
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
CWG2596 [temp.inst]/17 Instantiation of constrained non-template friends #47
Comments
I believe #1 is covered by https://eel.is/c++draft/temp.friend#9 . Those are in different 'scopes' since they have a constraint at all (as they are non-function templates). Had they been function templates, the constraint needs to refer to the enclosing template to get the 'different scope' protection of FWIW, I'm implementing this in Clang right now (it doesn't do it correctly) as part of the deferred concept implementation, and have a patch to implement MOST of that Itanium ABI proposal, but its held up on the concept patch, as well as Itanium not having done anything with that proposal yet. |
IMO, "in any other scope" in [temp.friend] p9 is not sufficiently clear.
Does it mean
or
or both? Furthermore, "any other scope" means different scopes or includes the same scope? Besides that, the example is regulated by [temp.friend] p9, I think. Moreover, "does not correspond to" is better than "does not declare the same" since [temp.friend] is introduced in [basic.scope.scope] p4 that is talking about whether two declarations correspond. [temp.inst]/17 ought to cover templated function cases in order to make it be clear that the satisfaction of the associated constraints is only checked in overload resolution or other contexts we need. Suggested resolution:change [temp.inst] p17 to
Not sure the complete intent of [temp.friend] p9, if we agree that it is applied to the first example, the same should be true for this example: struct Base {};
template<int N>
struct S : public Base {
friend int foo(Base&) requires (N == 1) { return 1; }
friend int foo(Base&) requires (N == 1) { return 1; }
}; However, all three compilers agree the latter is a redeclaration of the former. |
@erichkeane , "scope" per C++ is lexical (and yes, "other" means "not the same"). |
Shall we change "does not declare the same" in [temp.friend] p9 to "does not correspond to"? Since [basic.scope.scope] p4 cross-references [temp.friend], which is talking about whether two declarations correspond, we are looking forward to that [temp.friend] gives the case an answer that whether they correspond or not. Moreover, two declarations that do not correspond can never declare the same entity, so "does not correspond to" is better than "does not declare the same", I think.
|
This particular issue is about the instantiation question primarily. In order to fix [temp.friend] properly, the rule should simply be moved to the definition of "corresponds" in [basic.scope.scope] p4, but that's not in scope for CWG2596 (which is talking about instantiations, not about declaration correspondence). If the simple drive-by "inhabits" is not considered an improvement, it should simply be omitted. |
Full name of submitter: David Friberg
Reference (section label): [temp.inst]
Link to reflector thread (if any): -
Issue description:
As per US115 of P2103R0 hidden non-template friends may also use requires-clauses:
The current wording doesn't seem to cover what should happen at
#1
above: requires-clauses take effect during overload resolution, but what about instantiation of constrained (hidden) friends whose requires-clauses are not satisfied for the particular enclosing class template specialization being instantiated? Particularly [temp.inst]/17 doesn't cover friends as they are neither template specializations nor member functions:Implementation variance:
#1
for ODR-violations#2
, and generates the same mangled name for two different definitionsFor the latter, the Itanium C++ ABI currently does not allow unambiguously mangling these kind of friends. See itanium-cxx-abi/cxx-abi#24 (comment)
Suggested resolution:
To be discussed. Should be program above be well-formed?
The text was updated successfully, but these errors were encountered: