[Bug libstdc++/100516] [11/12 Regression] Unexpected -Wstringop-overread in deque<char> initialization from empty initializer_list

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jan 27 23:31:09 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100516

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:eae41b4d2cc30327f9f15c7390438c46aa09ed3f

commit r12-6907-geae41b4d2cc30327f9f15c7390438c46aa09ed3f
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Jan 27 22:31:26 2022 +0000

    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.


More information about the Gcc-bugs mailing list