[Bug c/50584] No warning for passing small array to C99 static array declarator

me at minglis dot id.au gcc-bugzilla@gcc.gnu.org
Wed Sep 25 10:21:00 GMT 2013


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

--- Comment #4 from Malcolm Inglis <me at minglis dot id.au> ---
I don't have a copy of the C99 standard, but IBM says [1] that if the function
is called with a pointer to a smaller array than specified with `static`, then
the behavior is undefined. Ergo, there should be a warning.

Could someone change the status of this bug?

I'm about 60% sure that I once played around with this in GCC, and it correctly
reported an error. This wouldn't have been too long ago; maybe 4.6 or even 4.7.

Clang emits a warning for this. [2]

I think this is a fantastic language feature. It's a shame GCC doesn't support
it yet.

[1]:
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/topic/com.ibm.xlcpp8a.doc/language/ref/param_decl.htm

[2]: http://hamberg.no/erlend/posts/2013-02-18-static-array-indices.html



More information about the Gcc-bugs mailing list