This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]