This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115f. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-06
[Accepted as a DR at the November, 2023 meeting.]
Paper P2169R4 (A nice placeholder with no name), as approved by WG21 in Varna, added a placeholder facility. The intent was that the use of placeholders is sufficiently limited such that they never need to be mangled. Quote from 6.4.1 [basic.scope.scope] paragraph 5 as modified by the paper:
A declaration is name-independent if its name is _ and it declares a variable with automatic storage duration, a structured binding not inhabiting a namespace scope, the variable introduced by an init-capture, or a non-static data member.
The following example does not seem to follow that intent:
struct A { A(); }; inline void f() { static union { A _{}; }; static union { A _{}; }; } void g() { return f(); }
The preceding example needs handling similar to the following example, which is unrelated to the placeholder feature:
struct A { A(); }; inline void f() { { static union { A a{}; }; } { static union { A a{}; }; } } void g() { return f(); }
A similar problem may arise for static or thread_local structured bindings at block scope.
Finally, another example involving placeholders in anonymous unions:
static union { int _ = 42; }; int &ref = _; int foo() { return 13; } static union { int _ = foo(); }; int main() { return ref; }
Possible resolution (reviewed by CWG 2023-08-25) [SUPERSEDED]:
Change in 6.4.1 [basic.scope.scope] paragraph 5 and add bullets as follows:
A class is name-dependent if it is an anonymous union declared at namespace scope or with a storage-class-specifier (11.5.2 [class.union.anon]). A declaration is name-independent if its name is _ and it declares
- a variable with automatic storage duration,
- a structured binding with no storage-class-specifier and not inhabiting a namespace scope,
- the variable introduced by an init-capture, or
- a non-static data member of other than a name-dependent class.
Proposed resolution (approved by CWG 2023-09-15):
Change in 6.4.1 [basic.scope.scope] paragraph 5 and add bullets as follows:
A declaration is name-independent if its name is _ and it declares
- a variable with automatic storage duration,
- a structured binding with no storage-class-specifier and not inhabiting a namespace scope,
- the variable introduced by an init-capture, or
- a non-static data member of other than an anonymous union.