Several issues about function parameter scope
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
A parameter-declaration-clause P introduces a function parameter scope that includes P.
- If P is associated with a declarator and is preceded by a (possibly-parenthesized) noptr-declarator of the form declarator-id attribute-specifier-seq opt, its scope extends to the end of the nearest enclosing init-declarator, member-declarator, declarator of a parameter-declaration or a nodeclspec-function-declaration, or function-definition, but does not include the locus of the associated declarator.
- If P is associated with a lambda-declarator, its scope extends to the end of the compound-statement in the lambda-expression.
- If P is associated with a requirement-parameter-list, its scope extends to the end of the requirement-body of the requires-expression.
- If P is associated with a deduction-guide, its scope extends to the end of the deduction-guide.
Please see this example:
using rt = auto(*)(int a)->decltype(a);
It's obviously P is not associated with any declarator instead with abstract-declarator, let alone whether it is preceded by noptr-declarator of the form declarator-id attribute-specifier-seq opt. In this example, the name of the parameter is used in the place that has exceeded the scope of the function parameter scope introduced by P. However, the case is valid in any major implementation other than MSVC. The other bullets are irrelevant with this case. So, it seems the function parameter scope is underspecified for this case.
Issue 2:
auto(* ptr(double a))(int b)->decltype(a);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ( int b )
init-declarator-> declarator-> noptr-declarator parameters-and-qualifiers trailing-return-type
^^^^^^^^^^^^^^^
( ptr-declarator )
↓
( ptr-operator ptr-declarator )
↓
( * noptr-declarator)
↓
( double a )
( * noptr-declarator parameters-and-qualifiers)
↓
( double a )
( * declarator-id parameters-and-qualifiers)
^^^^^^^^^
ptr
First of all, this case is rejected by all major implementations. Assume the parameter-declaration-clause that comprises the parameter declaration double a is called P1, the other(comprises int b) is called P2. As shown in the Figure, P1 is associated with the declarator of the complete declaration and is preceded by noptr-declarator of the form declarator-id attribute-specifier-seq opt that is ptr. In terms of the first bullet in the above, the scope should be extended to the nearest enclosing init-declarator (* ptr(double a))(int b)->decltype(a) since the other cases(member-declarator...) are all not suitable here. Hence, the use of the identifier a within decltype should be valid. But this conclusion is denied by implementations.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the parameter-declaration-clause scope rules quoted in the issue and examine both using rt = auto(*)(int a)->decltype(a); and the nested ptr(double a) example. Compare the stated rules with the behavior of the major implementations mentioned. Done means the specification clearly covers these abstract-declarator cases and resolves the implementation disagreement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100