N3011
Oops, Compound Literals with Empty Initializers

Published Proposal,

Previous Revisions:
None
Author:
Paper Source:
GitHub
Issue Tracking:
GitHub
Project:
ISO/IEC JTC1/SC22/WG14 9899: Programming Language — C
Proposal Category:
Editorial Fix
Target:
C23

Abstract

I forgot Compound Literals when writing N2900 - Consistent, Warningless, and Intuitive Initialization with {}.

1. Changelog

1.1. Revision 0 - June 17th, 2022

2. Introduction & Motivation

[N2900] forgot to update the grammar for compound literals, meaning that while the prose contained within for initialization technically includes compound literals, it is impossible to actually form a compound literal with an empty initializer.

This was seen as a mostly editorial fix, but unfortunately neither N2900 nor any minuted discussion ever actually spoke about this, likely because it was an afterthought to the issues we were resolving concerning the construct. As it stands, no compiler that actually implements empty brace initialization as an extension leaves this out. This was a needless failure on the part of the original author, JeanHeyd Meneide, for just not noticing.

I am sorry.

3. Wording

The following wording is registered against [N2912].

3.1. Modify §6.5.2 paragraph 1’s grammar

postfix-expression:

( type-name ) { initializer-list }

( type-name ) { initializer-list , }

( type-name ) { }

References

Informative References

[N2900]
JeanHeyd Meneide; Shepherd's Oasis. N2900: Consistent, Warningless, and Intuitive Initialization with {}. January 1st, 2022. URL: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2900.htm
[N2912]
ISO/IEC JTC1 SC22 WG14 - Programming Languages, C; JeanHeyd Meneide; Freek Wiedijk. N2912: ISO/IEC 9899:202x - Programming Languages, C. June 8th, 2022. URL: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2912.pdf