-
Notifications
You must be signed in to change notification settings - Fork 751
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
[temp.pre] Fix note about uniqueness of a template name in a scope #7284
base: main
Are you sure you want to change the base?
Conversation
There appears to be no implementation divergence on the example between 4 compilers: https://godbolt.org/z/axe9j9eTr |
Sorry, I don't understand the CI error about comments not being aligned. They seem aligned to me, even in the error message. |
See: Diagnostic could be WAY better there. |
Opened #7285 |
... and please squash all commits and force-push. |
a11dce4
to
aeb1e95
Compare
Should be good to go now. |
aeb1e95
to
91b5ed4
Compare
…clared in the same scope?" (#111446) [P1787R6](https://wg21.link/p1787r6): > [CWG110](https://cplusplus.github.io/CWG/issues/110.html) is resolved by reducing the restriction in [temp.pre] to a note (matching the behavior of GCC, Clang, and ICC). Wording: see changes to [temp.pre]/7 I believe the wording for the questions raised in the issue is now the definition of corresponding declarations that is given in [[basic.scope.scope]/4](https://eel.is/c++draft/basic.scope#scope-4): > Two declarations correspond if they (re)introduce the same name, both declare constructors, or both declare destructors, unless > — either is a using-declarator, or > — one declares a type (not a typedef-name) and the other declares a variable, non-static data member other than of an anonymous union ([class.union.anon]), enumerator, function, or function template, or > — each declares a function or function template and they do not declare corresponding overloads. Then it's used as an input for the definition of potentially conflicting declarations given in [[basic.scope.scope]/6](https://eel.is/c++draft/basic.scope#scope-6). Answering the question in the title: yes, having a function template and a type with the same name that has the same target scope is well-formed. A keen eye might spot that the current [[temp.pre]/7](https://eel.is/c++draft/temp.pre#7) note doesn't reflect all of the exceptions from the definition of corresponding declarations in [basic.scope.scope]/4, namely 4.1 and 4.2. I believe the note is defective, and I opened an editorial PR against the draft to fix that: cplusplus/draft#7284.
@jensmaurer Do you want me to do any further changes? |
https://eel.is/c++draft/temp.pre#7 was normative wording that was converted into a note by P1787R6. The first half of it reads:
I think it refers to wording about which declarations correspond (and consequently might conflict, rendering the program ill-formed), but it only reflects [basic.scope.scope]/4.3. The problem is that it's worded in a way that claims completeness, despite omitting 4.1 (using-declarators) and 4.2 (types not conflicting with non-types, including function templates).
This PR makes the note complete, and adds an example that focuses on function templates.