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

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

https://gcc.gnu.org/g:32f2b0f32816af816605dbe8060fb903cf7d5603

commit r13-7418-g32f2b0f32816af816605dbe8060fb903cf7d5603
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Tue Jun 6 11:38:42 2023 +0100

    libstdc++: Fix ambiguous expression in std::array<T, 0>::front() [PR110139]

    For 32-bit targets using -pedantic (or using Clang) makes the expression
    _M_elems[0] ambiguous.  The overloaded operator[] that we want to call
    has a size_t parameter, but 0 is type ptrdiff_t for many ILP32 targets,
    so using the implicit conversion from _M_elems to T* and then
    subscripting that is also viable.

    Change the 0 to (size_type)0 and also make the conversion to T*
    explicit, so that's it's not viable here. The latter change requires a
    static_cast in data() where we really do want to convert _M_elems to a
    pointer.

    libstdc++-v3/ChangeLog:

            PR libstdc++/110139
            * include/std/array (__array_traits<T, 0>::operator T*()): Make
            conversion operator explicit.
            (array::front): Use size_type as subscript operand.
            (array::data): Use static_cast to make conversion explicit.
            * testsuite/23_containers/array/element_access/110139.cc: New
            test.

    (cherry picked from commit 56001fad4ecc32396beead6644906e3846244b67)

Reply via email to