C++ Logo

std-discussion

Advanced search

Re: [dcl.array] State explicitly that only non-empty initializers allow the array bound to be omitted (editorial?).

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Fri, 1 May 2026 22:49:01 +0200
On 5/1/26 21:16, Maciej PolaƄski via Std-Discussion wrote:
> That's valuable input! So there is a consensus that the zero-size array
> is erroneous.
>
> I also discovered that this is explicitly prohibited by [dcl.init.aggr]
> 9.5.2.10.
> "An array of unknown bound shall not be initialized with an empty
> braced-init-list {}"
> https://eel.is/c++draft/dcl.init.aggr#10

Exactly, so the prohibition you seek is already present in the standard.

> I wonder if there is a rationale behind keeping zero-size arrays as the
> default. My guess is that it's a legacy of the initial C++11
> implementations.

Why don't you address this question to the gcc and clang
developers, who have opted to accept those empty arrays
in their (non-strict) implementation modes?

> What concerns me:
> 1. C/C++ is seen as difficult to learn by young programmers.

That sounds like non-young programmers would have a different
viewpoint, in your understanding. That's odd.

And what do you mean by the phrasing "C/C++"? This is
something that doesn't exist.

> 2. The implementation of arrays is effective, yet quite unusual compared
> to other languages, and it can be difficult to understand at first.
> 3. And yet some compilers have a trap for beginners, which is something
> to be aware of. Silent acceptance of obvious errors can hinder
> subsequent debugging attempts.

Use the pedantic modes of the compilers if you want conforming
behavior.

> I thought something should be changed, but now I've lost my confidence.

Great. In any case, a change you might seek in that area is neither
an obvious editorial nor a core issue, so please write a paper to
EWG.

Thanks,
Jens

Received on 2026-05-01 20:49:07