#Why isn't this crashing?
19 messages · Page 1 of 1 (latest)
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.
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
hmm, my kagi searching has led me to this: https://stackoverflow.com/questions/6452959/why-doesnt-my-program-crash-when-i-write-past-the-end-of-an-array
however I'm pretty sure on Windows that code would have crashed, would'nt it have?
Crashing is just one possibe outcome of UB.
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?
well i found literally my question - https://stackoverflow.com/questions/76895047/how-to-make-vectors-do-bound-checking-in-vs-code
Well using at is the best you can do.
you specify -D_GLIBCXX_DEBUG when compiling the code
I’m not sure how to do that with vscode, I’ll try to figure it out. Thank you
well, how do you compile the code?
@limpid pebble Has your question been resolved? If so, type !solved :)
i just click this:
i guess i'll have to dig into the options and see where all that is defined