Having tried it
int main (void) {int a [10]; and [20] = 5;}
int main (void) {
int a [10]; and [20] = 5;
}
gcc -wall -O2 main.c
This does not give me a warning ...
This is gcc in windows (mingw), and I cannot detect this border restriction error
how to tell the compiler to check it? can it do that?
thank
There are attempts to cope with checking the boundaries of the array. By default, the santdard C99 says nothing about applying array boundaries, I suppose, mainly because it has more overhead.
So you can look at sites like these, where people tried to deal with this:
http://williambader.com/bounds/example.html
, , , . SO . , , .
, , , . , gcc, clang (, ). .
, 4, 4:
ex9.c:17:2: warning: array index 4 is past the end of the array (which contains 4 elements) [-Warray-bounds] numbers[4] = 4; ^ ~ ex9.c:4:2: note: array 'numbers' declared here int numbers[4] = {0}; ^
Kajal
Source: https://habr.com/ru/post/1749397/More articles:How to show non-expandable nodes in a Powerbuilder Datawindow tree - treeGroup Testing of Hybrid WPF / Silverlight Controls - unit-testingSemantically correct tag for posting a forum message - htmlIs Embed Resource a good read-only xml database approach? - design-patternsDoes anyone know how I can change the color of file names on my model in emacs? - emacsПолучить случайное перечисление из выбранной группы - enumsReplace all escape sequences with nonequivalent equivalent strings in java - javaget environment (windows or unix) using jython - jythonApache POI Time Cell - javaПодключение к удаленному компьютеру с использованием WinNT://поставщик и службы каталогов Игнорирует имя пользователя/пароль - c#All Articles