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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Guess the problem is that we do:
              /* if (auto v = x<=>y, v == 0); else return v; */
              if (TREE_CODE (comp) == SPACESHIP_EXPR)
                TREE_TYPE (comp) = rettype;
              else
                comp = build_static_cast (input_location, rettype, comp,
                                          complain);
              info.check (comp);
              if (defining)
                {
                  tree var = create_temporary_var (rettype);
                  DECL_NAME (var) = get_identifier ("retval");
                  pushdecl (var);
                  cp_finish_decl (var, comp, false, NULL_TREE, flags);
                  comp = retval = var;
                }
              eq = build_new_op (info.loc, EQ_EXPR, flags, comp,
                                 integer_zero_node, NULL_TREE, NULL_TREE,
                                 NULL, complain);
so don't actually implement what the comment says, but instead emit
if (R v = x<=>y; v == 0); else return v;
where R is the return type of the defaulted operator<=>.
Now, if R is one of std::strong_ordering, std::weak_ordering or
std::partial_ordering, guess it makes no difference.  But when it is some
arbitrary other type, in this case const std::strong_ordering &, already the
TREE_TYPE (comp) = rettype; doesn't look right.  So wonder if the above code
except for the final eq = build_new_op shouldn't be guarded on if (cat_tag_for
(rettype) != cc_last) and otherwise it shouldn't implement what the comment
says (except , vs. ;),
so actually perform auto deduction.

Reply via email to