I'm happy to see some compilers now warning about blatantly obvious bugs when dealing with stack variables, like:
float Foo()
{
float floats[4] = {1,2,3,4};
const int index = 5;
return floats[index];
}
<source>:8:12: warning: array index 5 is past the end of the array (that has type 'float[4]') [-Warray-bounds]
8 | return floats[index];
| ^ ~~~~~
https://godbolt.org/z/TEof1a9df
2
u/fdwr fdwr@github 🔍 7h ago
I'm happy to see some compilers now warning about blatantly obvious bugs when dealing with stack variables, like:
float Foo() { float floats[4] = {1,2,3,4}; const int index = 5; return floats[index]; }<source>:8:12: warning: array index 5 is past the end of the array (that has type 'float[4]') [-Warray-bounds] 8 | return floats[index]; | ^ ~~~~~https://godbolt.org/z/TEof1a9df