This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/50584] No warning for passing small array to C99 static array declarator
- From: "fredrik dot hederstierna at securitas-direct dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 16 May 2017 14:21:22 +0000
- Subject: [Bug c/50584] No warning for passing small array to C99 static array declarator
- Auto-submitted: auto-generated
- References: <bug-50584-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584
Fredrik Hederstierna <fredrik.hederstierna@securitas-direct.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fredrik.hederstierna@securi
| |tas-direct.com
--- Comment #14 from Fredrik Hederstierna <fredrik.hederstierna@securitas-direct.com> ---
Still present in GCC-7.1.0
Simple test code:
-------------------------------------
int s[1] = { 1 };
void test(int v[static 2])
{
printf("%d\n", v[1]);
v[1] = 0;
}
int main(void)
{
test(s);
return 0;
}
-------------------------------------
No warnings by GCC:
> gcc -c test.c -W -Wall -Wextra -Warray-bounds -O2 -std=c99
-------------------------------------
But with CLANG-3.8.0 we get warnings:
> clang -c test.c
test.c:13:3: warning: array argument is too small; contains 1 elements, callee
requires at least 2 [-Warray-bounds]
test(s);
^ ~
test.c:5:15: note: callee declares array parameter as static here
void test(int v[static 2])
^~~~~~~~~~~
1 warning generated.