[basic.lookup.argdep] should also perform if function declaration is not found
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
[basic.lookup.argdep] p1 says
When the postfix-expression in a function call ([expr.call]) is an unqualified-id, and unqualified lookup ([basic.lookup.unqual]) for the name in the unqualified-id does not find any
This implies/asserts that the unqualified name lookup at least finds one function or function template declaration because [expr.call] p1 says that:
A function call is a postfix expression followed by parentheses containing a possibly empty, comma-separated list of initializer-clauses which constitute the arguments to the function. The postfix expression shall have function type or function pointer type.
In other words, if the postfix expression is not of function type or function pointer type, "a postfix expression followed by parentheses..." cannot be considered as a function call(e.g., Explicit type conversion (functional notation)).
Consider this exmple:
namespace A{
namespace B{
struct X{};
void fun(X,char);
}
void invoke(){
fun(B::X{},0); // #1
}
}
The unqualified name lookup for fun at #1 will find nothing however ADL can find the function declaration in A::B. Should we say that?
After an unqualified lookup performs for an expression that has a form:
postfix-expression ( expression-listopt )
where postfix-expression is an unqualified-id and the result of the unqualified lookup ([basic.lookup.unqual]) for the name does not include any:
- declaration of a class member,
orand- function declaration inhabiting a block scope,
orand- declaration not of a function or function template
then lookup for the name also includes the result of argument-dependent lookup in a set of associated namespaces that depends on the types of the arguments (and for template template arguments, the namespace of the template argument), as specified below.
Seems that the "or" in the original list should be removed and should be replaced with "and" instead. Actually, only all bullets are satisfied will ADL perform for that name. However, "or" sounds like that merely needs one of the bullets to be satisfied. Also, we should admit that ADL only performs for an unqualified name after the unqualified name lookup has been completed and only if the result of that unqualified name lookup does not violate the above bullets.
namespace A{
namespace B{
struct X{};
void fun(X,char);
}
void fun(); // #1
struct fun{}; // #2
void invoke(){
fun(B::X{},0);
}
}
In this example, unqualified name lookup does find the class definition at #2, merely, it is discarded from the result. So, we say "the result of the unqualified lookup ([basic.lookup.unqual]) for the name does not include any..." seems to be clearer.
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 with the [basic.lookup.argdep] and [expr.call] paragraphs quoted in the issue, then compare the two examples showing missing and discarded unqualified lookup results. No file or test is named; done means agreeing on whether the wording should cover the examples and resolving the proposed “and”/“or” and lookup-order clarifications.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100