[conv.general] Note misuses «destination type»
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
As we know,
16 The semantics of initializers are as follows.The destination type is the type of the object or reference being initialized
Now the Note:
2 [Note 2: Expressions with a given type will be implicitly converted to other types in several contexts:
(2.1) When used as operands of operators. The operator's requirements for its operands dictate the destination type ([expr.compound]).
(2.2) When used in the condition of an if statement ([stmt.if]) or iteration statement ([stmt.iter]). The destination type is bool.
(2.3) When used in the expression of a switch statement ([stmt.switch]). The destination type is integral.
(2.4) When used as the source expression for an initialization (which includes use as an argument in a function call and use as the expression in a return statement).
The type of the entity being initialized is (generally) the destination type. See [dcl.init], [dcl.init.ref].
— end note]
The operator's requirements for its operands dictate the destination type
is wrong, because a built-in operator's operand is not an «object or reference being initialized»
(2.2) is kinda OK, because implicit conversion to bool is modeled as declaration bool t(E);
(2.3) is wrong. Class types are contextually implicitly converted (http://eel.is/c++draft/stmt.switch#2.sentence-3), and this conversion is described not relying on initialization http://eel.is/c++draft/conv.general#def:contextually_implicitly_converted
(2.4) is, obviously, OK
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 at the [conv.general] note and compare its statements about destination types with the cited [dcl.init.general], [stmt.if], [stmt.iter], and [stmt.switch] clauses. Check the definition of contextually implicitly converted as well; done means the note accurately describes each conversion context without treating every operand as an initialized object or reference.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, tex
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100