Hacker News new | ask | show | jobs
by hoppelhase 2730 days ago
As this is valid, but only useful as documentation:

    void foo(const int n, const char data[n])
Is this also valid?

    void foo(const int n, const char data[static n])
1 comments

The `n` may be any assignment-expression, and as a result values like `n` are appear to be allowed by the standard.

I've used this in code compiled with gcc and clang. Both accept this construct, but I'm not sure how effectively any compiler is able to use this information to emit warnings/errors.