cplusplus / cplusplus/draft

[over.best.ics.general] The type of parameter is unclear

Open
#5,369 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

[over.best.ics.general] p1 says

An implicit conversion sequence is a sequence of conversions used to convert an argument in a function call to the type of the corresponding parameter of the function being called.

[over.best.ics.general] p6 says

When the parameter type is not a reference, the implicit conversion sequence models a copy-initialization of the parameter from the argument expression. The implicit conversion sequence is the one required to convert the argument expression to a prvalue of the type of the parameter.

Consider this example:

void fun(int a()){
}
fun(0);

Is the type of the parameter a be considered as function of () returning int or "pointer to function of () returning int" that is after adjustment?

Since [dcl.fct.note] p3 says

This transformation does not affect the types of the parameters.

The parameter-declaration int a() matches [dl.fct] and thus it's original type is function type. Does the type of the parameter mean the type of the parameter in parameter-type-list? Such as

void fun(int a(), int const b){}
fun(0,0);

For the purpose of defining implicit conversion sequence, the type of a and b are pointer to function of () returning int and int, respectively.

BTW, the adjustment for the types of parameters that is "array of T" or "function type T" does not only affect parameter-type-list but also affect the type when determining the type of the entity, such as the result of decltype(a) is pointer to function of () returning int rather than function of () returning int but decltype(b) is exactly const int. [dcl.fct] p5 may need to be improved to make that meaning clear.

After determining the type of each parameter, any parameter of type “array of T” or of function type T is adjusted to be “pointer to T”. After producing the list of parameter types, any top-level cv-qualifiers modifying a parameter type are deleted when forming the function type. The resulting list of transformed parameter types and the presence or absence of the ellipsis or a function parameter pack is the function's parameter-type-list.

This sounds like all transformations only affect the determination of the function's parameter-type-list.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the wording in [over.best.ics.general], [dcl.fct.note], and [dcl.fct], then examine the fun(int a()) and fun(int a(), int const b) examples. Clarify whether “type of the parameter” refers to the adjusted parameter type or the original declared type, and revise the wording so the intended behavior of decltype and implicit conversion sequences is unambiguous.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.