https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

--- Comment #10 from Serg Iv <sergei.ivn+bugzilla at gmail dot com> ---
Some thoughts after I read C99 rationale.

Actually, [static N] it's a PROMISE to a compiler, that programmer will always
provide N pieces of data. *ALWAYS*.
Therefore compiler can do with this data whatever it wants. It can, for
instance, copy it (all N elements) somewhere to some local cache for
optimization. Or send it into the space towards the Ape Planet to use brand new
Appe book for calculations.
If the programmer didn't provide N pieces of the information - we may have
segfault, crash, bsod or nuclear war, it depends. It not a compiler's headache,
it's a programmer fault.

So, IMO the right way for GCC is 
a) if it get NULL pointer through all optimization or smaller array is provided
- error in compile time
b) if func's supplied with an array lenght >= N, compile without errors and
warnings
c) otherwise - warning.

Reply via email to