[Bug c++/69852] std::vector out of bounds access does not crash
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Feb 17 13:44:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69852
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Your program has undefined behaviour, so you are wrong to expect it to crash,
anything can happen. Please read http://c-faq.com/ansi/experiment.html
If you want the error to be noticed then compile with -D_GLIBCXX_DEBUG to
enable additional checking, which produces:
Before assignment: size 6 capacity 6
After assignment: size 0 capacity 6
/home/jwakely/gcc/6/include/c++/6.0.0/debug/vector:415:
Error: attempt to subscript container with out-of-bounds index 1, but
container only holds 0 elements.
Objects involved in the operation:
sequence "this" @ 0x0x7ffed6157160 {
type = std::__debug::vector<std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >;
}
Aborted (core dumped)
More information about the Gcc-bugs
mailing list