This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/69852] std::vector out of bounds access does not crash
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 17 Feb 2016 13:44:49 +0000
- Subject: [Bug c++/69852] std::vector out of bounds access does not crash
- Auto-submitted: auto-generated
- References: <bug-69852-4 at http dot gcc dot gnu dot org/bugzilla/>
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)