This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] proposed fix for libstdc++/59829


This is the best I've come up with to avoid undefined behaviour when
calling vector::data() on an empty vector.

In C++03 mode we return vector::pointer, so can just return the
internal pointer. In C++11 mode we need to dereference it, but only
when it's valid.

Any suggestions for improvements before I commit it?
(Tests pass, but some dg-error line numbers need adjusting)

2014-01-27  Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/59829
	* include/bits/stl_vector.h (vector::data()): Do not dereference
	pointers when empty.

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]