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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

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

commit r11-6305-gffd454b92ba6ff5499cf57f82a2b0f4cee59978c
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Tue Dec 22 20:18:10 2020 +0100

    c++: Handle array members in build_comparison_op [PR93480]

    http://eel.is/c++draft/class.compare.default#6 says for the
    expanded list of subobjects:
    "In that list, any subobject of array type is recursively expanded
    to the sequence of its elements, in the order of increasing subscript."
    but build_comparison_op just tried to compare the whole arrays, which
    failed and therefore the defaulted comparison was deleted.

    The following patch instead compares the array elements, and
    if info.defining, adds runtime loops around it so that it iterates
    over increasing subscripts.

    For flexible array members it punts, we don't know how large those will be,
    for zero sized arrays it doesn't even try to compare the elements,
    because if there are no elements, there is nothing to compare, and
    for [1] arrays it will not emit a loop because it is enough to use
    [0] array ref to cover everything.

    2020-12-21  Jakub Jelinek  <ja...@redhat.com>

            PR c++/93480
            * method.c (common_comparison_type): If comps[i] is a TREE_LIST,
            use its TREE_VALUE instead.
            (build_comparison_op): Handle array members.

            * g++.dg/cpp2a/spaceship-synth10.C: New test.
            * g++.dg/cpp2a/spaceship-synth-neg5.C: New test.

Reply via email to