]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Prevent -Wstringop-overread warning in std::deque [PR100516]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 27 Jan 2022 22:31:26 +0000 (22:31 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 27 Jan 2022 23:31:03 +0000 (23:31 +0000)
commiteae41b4d2cc30327f9f15c7390438c46aa09ed3f
tree650a9486da7a44d6eedad6d909d64d813ce82d67
parent00e7d024afb80e95fb36d74b1c059468d883a850
libstdc++: Prevent -Wstringop-overread warning in std::deque [PR100516]

The compiler warns about the loop in deque::_M_range_initialize because
it doesn't know that the number of nodes has already been correctly
sized to match the size of the input. Use __builtin_unreachable to tell
it that the loop will never be entered if the number of elements is
smaller than a single node.

libstdc++-v3/ChangeLog:

PR libstdc++/100516
* include/bits/deque.tcc (_M_range_initialize<ForwardIterator>):
Add __builtin_unreachable to loop.
* testsuite/23_containers/deque/100516.cc: New test.
libstdc++-v3/include/bits/deque.tcc
libstdc++-v3/testsuite/23_containers/deque/100516.cc [new file with mode: 0644]