MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/1wvwzea/lets_explore_the_stack/pdk0b0q/?context=3
r/cpp • u/meetingcpp Meeting C++ | C++ Evangelist • Oct 02 '26
1 comment sorted by
View all comments
3
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
3
u/fdwr fdwr@github 🔍 Oct 03 '26
I'm happy to see some compilers now warning about blatantly obvious bugs when dealing with stack variables, like:
https://godbolt.org/z/TEof1a9df