Date: Mon, 27 Apr 2026 18:10:41 +0000
GCC and Clang only claim standard compliance when -pedantic is used, and with this option, they both issue a diagnostic (an error for GCC, a warning for Clang). So I don't think your proposed text would require them to change anything.
I wouldn't say they are treating it as "legal". They both provide zero-length arrays as a clearly documented extension, which they readily acknowledge is non-standard. A user who wants to avoid such extensions and receive all standard-mandated diagnostics should know to use -pedantic.
You may very well think that the -pedantic behavior should be their default, to avoid such instances of confusion, and you could take that up with their developers, but it's outside the jurisdiction of the standard.
> On Apr 27, 2026, at 11:51, Maciej Polański via Std-Discussion <std-discussion_at_[hidden]> wrote:
>
> Dear Group,
>
> Please let me know if the world needs this fix and if it could count as an editorial. So:
>
> The following variable declaration is not allowed and should result in an error:
> int arr[];
> However, due to an unclear wording in The Standard, the following statement is legal on many compilers, though UB:
> int arr[]{};
> I'll be glad to be proved wrong if there's a legal use for `int arr[]{}`.
>
> The current "state of the art" is that GCC and Clang allow a zero-sized array if the bounds are omitted and followed by an empty initializer. MSVC is more cautious and prevents developers from experiencing the consequences of their errors. I suppose the authors of all the compilers think they are compliant on this issue.
> https://godbolt.org/z/jbbcnqP9K
>
> In my opinion, the problem lies in interpreting the unfortunate wording of The Standard [decl.array] "9.3.4.5 Arrays - 7" without proper context:
> "An array bound may also be omitted when an object (but not a non-static data member) of array type is initialized and the declarator is followed by an initializer"
> https://eel.is/c++draft/dcl.decl#dcl.array-7
> This paragraph does not explicitly exclude empty initializers. In the case of arrays, "empty" means "nothing," which may result in undefined behavior (UB).
>
> But, in my opinion, the compiler should interpret the paragraph above in the context of the following:
> 1. "[decl.array] 9.3.4.5 Arrays - 1" That explicitly states that the array bound "N shall be greater than zero".
> 2. "[dcl.init.general] 9.5.1 General - 16.5" That describes use of an initializer for an array and requires "1 <= i <= k," where k is the initializer size.
>
> In my opinion, the solution could be as simple as rewording "followed by an initializer" to "followed by a non-empty initializer."
>
>
> This issue surfaced during, not directly related to it, StackOverflow discussion:
> https://stackoverflow.com/questions/78941074/accessing-and-modifying-array-elements/78941410#78941410
> Among other mistakes, the author used a zero-size array. As the StackOverflow question showed, this mistake happens among beginners. Perhaps some think that zero-size arrays are self-extending, as many scripting languages have this feature. Therefore, it could be helpful to prevent zero-size array cases.
>
> The arguments for classifying this as an editorial are as follows:
> It is obvious that no zero-size arrays exist.
> Rule "Unclear writing, when the intention of the text in question is well-known to the committee, but the presentation could be clearer".
> There should also be no impact on existing programs, as those using zero-size are likely already broken.
> Against:
> This removes UB, which may affect some really exotic cases. Such changes may require formal paper.
>
> Even though I have a hard time accepting criticism, I welcome all opinions :)
>
> Maciej Polański
> MaciejPolanski75_at_[hidden]
>
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
I wouldn't say they are treating it as "legal". They both provide zero-length arrays as a clearly documented extension, which they readily acknowledge is non-standard. A user who wants to avoid such extensions and receive all standard-mandated diagnostics should know to use -pedantic.
You may very well think that the -pedantic behavior should be their default, to avoid such instances of confusion, and you could take that up with their developers, but it's outside the jurisdiction of the standard.
> On Apr 27, 2026, at 11:51, Maciej Polański via Std-Discussion <std-discussion_at_[hidden]> wrote:
>
> Dear Group,
>
> Please let me know if the world needs this fix and if it could count as an editorial. So:
>
> The following variable declaration is not allowed and should result in an error:
> int arr[];
> However, due to an unclear wording in The Standard, the following statement is legal on many compilers, though UB:
> int arr[]{};
> I'll be glad to be proved wrong if there's a legal use for `int arr[]{}`.
>
> The current "state of the art" is that GCC and Clang allow a zero-sized array if the bounds are omitted and followed by an empty initializer. MSVC is more cautious and prevents developers from experiencing the consequences of their errors. I suppose the authors of all the compilers think they are compliant on this issue.
> https://godbolt.org/z/jbbcnqP9K
>
> In my opinion, the problem lies in interpreting the unfortunate wording of The Standard [decl.array] "9.3.4.5 Arrays - 7" without proper context:
> "An array bound may also be omitted when an object (but not a non-static data member) of array type is initialized and the declarator is followed by an initializer"
> https://eel.is/c++draft/dcl.decl#dcl.array-7
> This paragraph does not explicitly exclude empty initializers. In the case of arrays, "empty" means "nothing," which may result in undefined behavior (UB).
>
> But, in my opinion, the compiler should interpret the paragraph above in the context of the following:
> 1. "[decl.array] 9.3.4.5 Arrays - 1" That explicitly states that the array bound "N shall be greater than zero".
> 2. "[dcl.init.general] 9.5.1 General - 16.5" That describes use of an initializer for an array and requires "1 <= i <= k," where k is the initializer size.
>
> In my opinion, the solution could be as simple as rewording "followed by an initializer" to "followed by a non-empty initializer."
>
>
> This issue surfaced during, not directly related to it, StackOverflow discussion:
> https://stackoverflow.com/questions/78941074/accessing-and-modifying-array-elements/78941410#78941410
> Among other mistakes, the author used a zero-size array. As the StackOverflow question showed, this mistake happens among beginners. Perhaps some think that zero-size arrays are self-extending, as many scripting languages have this feature. Therefore, it could be helpful to prevent zero-size array cases.
>
> The arguments for classifying this as an editorial are as follows:
> It is obvious that no zero-size arrays exist.
> Rule "Unclear writing, when the intention of the text in question is well-known to the committee, but the presentation could be clearer".
> There should also be no impact on existing programs, as those using zero-size are likely already broken.
> Against:
> This removes UB, which may affect some really exotic cases. Such changes may require formal paper.
>
> Even though I have a hard time accepting criticism, I welcome all opinions :)
>
> Maciej Polański
> MaciejPolanski75_at_[hidden]
>
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
Received on 2026-04-27 18:10:47
