CWG Issue 2144 (original) (raw)
This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 117a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-04-13
2144. Function/variable declaration ambiguity
Section: 9.6.1 [dcl.fct.def.general]Status: DRWPSubmitter: Richard SmithDate: 2015-06-19
[Accepted as a DR at the June, 2024 meeting.]
The following fragment,
int f() {};
is syntactically ambiguous. It could be either a_function-definition_ followed by an empty-declaration, or it could be a simple-declaration whose_init-declarator_ has the brace-or-equal-initializer {}. The same is true of a variable declaration
int a {};
since function-definition simply uses the term declarator in its production.
Additional notes (May, 2024)
Issue 2876 introduced a framework to distinguish the parsing. Its resolution was extended to also resolve this issue.