#Why isn't this crashing?

19 messages · Page 1 of 1 (latest)

limpid pebble
#

Hello, I just switched to Linux and am trying to learn how to switch from VS to VSCode. I want to see what happens when code crashes to see if I can explore the stack and variables like I can on Windows... but i just discovered that this code doesn't crash. Can anyone help me to understand why?

lapis reefBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

limpid pebble
#

if i don't push_back anything into vec, then it does segfault as expected

#

however if I put two items into vec, then try to write to vec[4] and even read from vec[4] it doesn't crash!

#

and the output is: vec[4] is: 4

wet fractal
#

Crashing is just one possibe outcome of UB.

limpid pebble
#

on windows in debug mode, I'm pretty sure that would have been caught though

#

i would love to use visual studio but I can't do that on linux

#

how can I get that safety back for debug mode?

wet fractal
#

Well using at is the best you can do.

mental girder
limpid pebble
mental girder
#

well, how do you compile the code?

lapis reefBOT
#

@limpid pebble Has your question been resolved? If so, type !solved :)

limpid pebble
#

i guess i'll have to dig into the options and see where all that is defined