This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/29787] std::vector can access negative value (std runtime bug?)
- From: "fang at csl dot cornell dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Nov 2006 23:37:00 -0000
- Subject: [Bug c++/29787] std::vector can access negative value (std runtime bug?)
- References: <bug-29787-13541@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from fang at csl dot cornell dot edu 2006-11-09 23:37 -------
If you want bounds checking on std::vector, use the "at()" member function in
place of operator[].
Otherwise, the overloaded operator[] is unchecked and just does a plain
indexed-array reference.
(If it is out-of-bounds, an exception will be thrown.)
--
fang at csl dot cornell dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fang at csl dot cornell dot
| |edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29787