Liste des Groupes | Revenir à cl c |
On 09/02/2025 19:19, Michael S wrote:On Sun, 9 Feb 2025 18:46:44 +0100
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
wrong! - assignment to 'a[99]' produced also no compiler
complaints,
gcc produces warning in this case, but only at optimization level
of 2 or higher.
Which version of gcc?
Tried with gcc 14.2 (x86-64) with -Wall -O3 (or -O2, same), it
doesn't give any warning whatsoever. (And yes, same with clang.)
Cppcheck does spot it properly though:
error: Array 'arr[5]' accessed at index 99, which is out of bounds.
[arrayIndexOutOfBounds]
arr[99] = "foobar";
I highly recommend using Cppcheck as a static analyzer (at the bare
minimum, there are better out there). Compilers are pretty basic in
terms of static analysis.
Les messages affichés proviennent d'usenet.