2 ms·
Note that GCC does (sometimes) detect the misuse of the "int a[static 3]" case, but maybe that is only when the length is a compile time constant; and possibly
by dfawcus 2y ago
Note that GCC does (sometimes) detect the misuse of the "int a[static 3]" case, but maybe that is only when the length is a compile time constant; and possibly only with char arrays.
$ make texe
cc -g -O2 -std=c11 -Wall -Wextra -Wpedantic -Werror -c -o test.o test.c
test.c: In function ‘do_test_formatSmallElem’:
test.c:108:9: error: ‘matSmallElemFormat’ accessing 8 bytes in a region of size 2 [-Werror=stringop-overflow=]
108 | matSmallElemFormat(elem, buffer);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.c:108:9: note: referencing argument 2 of type ‘char *’
In file included from test.c:8:
mat/display.h:17:6: note: in a call to function ‘matSmallElemFormat’
17 | void matSmallElemFormat(mElem elem, char buffer[static matSmallElemLen]);
| ^~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [<builtin>: test.o] Error 1