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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Jonathan Wakely
<r...@gcc.gnu.org>:

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

commit r15-9952-gab3781665da064985d66de0c895cc43588179cb6
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Tue Jul 8 14:56:39 2025 +0100

    libstdc++: Do not use list-initialization in std::span members [PR120997]

    As the bug report shows, for span<const bool> the return statements of
    the form `return {data(), count};` will use the new C++26 constructor,
    span(initializer_list<element_type>).

    Although the conversions from data() to bool and count to bool are
    narrowing and should be ill-formed, in system headers the narrowing
    diagnostics are suppressed. In any case, even if the compiler diagnosed
    them as ill-formed, we still don't want the initializer_list constructor
    to be used. We want to use the span(element_type*, size_t) constructor
    instead.

    Replace the braced-init-list uses with S(data(), count) where S is the
    correct return type. We need to make similar changes in the C++26
    working draft, which will be taken care of via an LWG issue.

    libstdc++-v3/ChangeLog:

            PR libstdc++/120997
            * include/std/span (span::first, span::last, span::subspan): Do
            not use braced-init-list for return statements.
            * testsuite/23_containers/span/120997.cc: New test.

    (cherry picked from commit a72d0e1a8bf0770ddf1d8d0ebe589f92a4fab4ef)

Reply via email to