Menu ▾ ▴

#4224 Array declarators with incomplete element types are silently accepted

open
nobody
None
Front-end
5
2026-10-24
2026-10-24
No

1: Sample code that reproduces the problem.

struct S;
typedef struct S A[2];

2: Exact command used to run SDCC on this sample code.

sdcc -mz80 --std=c2y --nostdinc -S bug.c -o bug.asm

3: SDCC version tested.

SDCC 4.6.4 #17068 (Linux), tested 23 October 2026.

4: Observed and expected behaviour.

SDCC exits successfully and emits no diagnostic.

N3886 6.7.7.3 paragraph 1 requires the element type of an array declarator to be neither incomplete nor a function type. This constraint applies when the array type is specified; creating an array object is not required. A diagnostic is required.

Reference: N3886.

5: Additional checks.

These variants are also accepted silently:

typedef int A[2][];
struct S;
struct S (*p)[2];

Defining struct S before the array typedef, or using struct S *p, compiles silently on all five targets.

Related closed report [bugs:#1163] concerned incomplete element types in structure members. That context still receives error 200 in r17068. These cases demonstrate a gap outside member declarations.

N3839 proposes relaxing this rule for C2Y. This report concerns the rule in N3886 and the existing C99, C11 and C23 modes; all four modes were tested.

All invalid variants above were accepted without diagnostics on Z80, MCS51, STM8, PDK14 and MOS6502 in each of C99, C11, C23 and C2Y modes. GCC 13.3.0 with -std=c2x -pedantic-errors -fsyntax-only rejects them. The GCC comparison is a local run; GCC 16.2 and Clang were not tested.

Related

Bugs: #1163

Discussion


Log in to post a comment.