_FORTIFY_SOURCE for std::vector
Florian Weimer
fweimer@redhat.com
Fri Jun 1 11:01:00 GMT 2012
I forgot to send this to the libstdc++ list the first time.
This patch evaluates _FORTIFY_SOURCE in a way similar to GNU libc.
If set, std::vector::operator[] throws if the index is out of bounds.
This is compliant with the standard because such usage triggers
undefined behavior. _FORTIFY_SOURCE users expect some performance hit.
In contrast to debugging mode, this does not change ABI and is more
widely applicable.
Okay for trunk?
2012-05-29 Florian Weimer <fweimer@redhat.com>
* include/bits/stl_vector.h (vector::_M_fortify_range_check):
New.
* (vector::operator[]): Call it.
* testsuite/23_containers/vector/element_access/2.cc: New.
--
Florian Weimer / Red Hat Product Security Team
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fortify-vector.diff
Type: text/x-patch
Size: 3112 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20120601/a2b5dd6f/attachment.bin>
More information about the Libstdc++
mailing list