Skip to content

Comment on A nice, little known C feature: Static array indices in parameter declarationsparent

Comments

According to section 6.7.5.2p1 of C99: “If the expression is a constant expression, it shall have a value greater than zero.”

The “expression” here refers to an expression in between [] in an array declaration; so the declaration of size 0 is a constraint violation and requires a diagnostic. You can get gcc and clang to issue a relevant diagnostic with “-std=c99 -pedantic”.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.