New issue
Advanced search Search tips

Issue 869870 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Aug 1
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

base::size fails for empty arrays.

Project Member Reported by rhalavati@chromium.org, Aug 1

Issue description

base::size() does not compile when array size is zero.
 
Owner: jdoerrie@chromium.org
Status: Assigned (was: Untriaged)
@jdoerrie who implemented base::size
Status: WontFix (was: Assigned)
I'm assuming you are talking about C arrays, as it's working fine for empty std::arrays. Here the compilation failure is actually working as intended, as zero-length arrays are not allowed by the standard [1]:

"""
[...] If the constant-expression is present, it shall be a converted constant expression of type std​::​size_­t and its value shall be greater than zero. [...]
"""

A small reproduction case is here: https://godbolt.org/g/wTsb7R. Because of this, I am marking this as WontFix. Would it be possible for you to use an empty std::array to work around this?


[1] http://eel.is/c++draft/dcl.array#1

Sign in to add a comment