Created on 2016-02-02.00:00:00 last changed 25 months ago
Proposed resolution (January, 2019):
Consider:
int x = (int()) + 5;
This is ill-formed, because 9.3.3 [dcl.ambig.res] paragraph 2 specifies:
An ambiguity can arise from the similarity between a function-style cast and a type-id. The resolution is that any construct that could possibly be a type-id in its syntactic context shall be considered a type-id.
and thus int() is interpreted as a type-id instead of as a function-style cast, so this is an ill-formed cast to a function type.
This seems to be the wrong disambiguation for all cases where there is a choice between a C-style cast and a parenthesized expression: in all those cases, the C-style cast interpretation results in a cast to a function type, which is always ill-formed.
Further, there is implementation divergence in the handling of this example:
struct T { int operator++(int); T operator[](int); };
int a = (T()[3])++; // not a cast
EWG 2022-11-11
This is tracked in github issue cplusplus/papers#1376.
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-11-10 15:00:26 | admin | set | status: review -> open |
2020-12-15 00:00:00 | admin | set | messages: + msg6222 |
2020-12-15 00:00:00 | admin | set | status: drafting -> review |
2018-02-27 00:00:00 | admin | set | status: open -> drafting |
2016-02-02 00:00:00 | admin | create |