Skip to content

CWG 3121 [dcl.fct] Zero-size arrays in function parameters are not allowed #797

Description

@eisenwave

Reference (section label): [dcl.fct] paragraph 4

Jens wants a CWG issue for this; see cplusplus/draft#6575 (comment) for previous discussion.

Issue description

Implementations diverge (https://godbolt.org/z/q5bjWEs8o) on whether the following declaration is ill-formed:

void foo(int[0]);

While [dcl.fct] paragraph 4 states that array parameter types are adjusted to pointer types, [dcl.array] paragraph 1 clearly states that a zero-length array is not a valid type in the first place.

It should be clarified that parameter type adjustment does not legitimize zero-length arrays in function parameters.

Proposed resolution

Expand [dcl.fct] example 2 as follows:

 ...
 void h(int (*)(int)) {}         // defines #3
+
+void j(int[0]);                 // error: int[0] is not a valid type

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions