libstdc++: Make deque iterator operator- usable with value-init iterators
authorFrançois Dumont <fdumont@gcc.gnu.org>
Thu, 28 Jan 2021 18:00:56 +0000 (19:00 +0100)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Mon, 1 Feb 2021 18:19:53 +0000 (19:19 +0100)
commit33a1e511b57465d898429740377466894a0b247d
treee95166c245283bfb7dd3120a3673ae0ee5e4ff9d
parent11056ab7687f7156846e93557c9171b77713bd7e
libstdc++: Make deque iterator operator- usable with value-init iterators

N3644 implies that operator- can be used on value-init iterators. We now return
0 if both iterators are value initialized. If only one is value initialized we
keep the UB by returning the result of a normal computation which is a meaningless
value.

libstdc++-v3/ChangeLog:

PR libstdc++/70303
* include/bits/stl_deque.h (std::deque<>::operator-(iterator, iterator)):
Return 0 if both iterators are value-initialized.
* testsuite/23_containers/deque/70303.cc: New test.
* testsuite/23_containers/vector/70303.cc: New test.
libstdc++-v3/include/bits/stl_deque.h
libstdc++-v3/testsuite/23_containers/deque/70303.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/vector/70303.cc [new file with mode: 0644]