On Thu, May 21, 2026 at 01:37:45PM -0400, Jason Merrill wrote:
> On 5/21/26 11:46 AM, Marek Polacek wrote:
> > On Thu, May 21, 2026 at 10:49:09AM -0400, Patrick Palka wrote:
> > > On Thu, 21 May 2026, Marek Polacek wrote:
> > > > > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
> > > > > index 02a62f78511c..8af3bd6f4641 100644
> > > > > --- a/gcc/cp/tree.cc
> > > > > +++ b/gcc/cp/tree.cc
> > > > > @@ -3855,6 +3855,17 @@ build_min_non_dep_op_overload (enum tree_code 
> > > > > op,
> > > > >         tree spaceship_non_dep = (TREE_CODE (non_dep) == CALL_EXPR
> > > > >                                   ? CALL_EXPR_ARG (non_dep, reversed 
> > > > > ? 1 : 0)
> > > > >                                   : TREE_OPERAND (non_dep, reversed ? 
> > > > > 1 : 0));
> > > > > +
> > > > > +       bool int_promotion = false;
> > > > > +       if (TREE_CODE (spaceship_non_dep) == NOP_EXPR)
> > > > > +         {
> > > > > +           gcc_checking_assert (TREE_CODE (non_dep) != CALL_EXPR);
> > > > > +           gcc_checking_assert (TREE_TYPE (spaceship_non_dep)
> > > > > +                                == integer_type_node);
> > > > 
> > > > It seems to me this should also check unsigned_type_node for the
> > > > rare case we get promotion to unsigned int.
> > > 
> > > I wasn't able to come up with a testcase where we get an unsigned int
> > > promotion in the rewritten form.  Even if operator<=> returns e.g.
> > > unsigned char we still always see an int promotion it seems.
> > 
> > I thought we could get there with certain enums (INT_MAX + 1), but
> > I'm unable to trigger that.  So we would need some exotic platform
> > where sizeof (short) == sizeof (int) to get the crash.  So, dunno,
> > maybe it's good as-is.
> 
> We might as well have the new local variable record the type of the NOP_EXPR
> rather than bool.  OK with that change.

FWIW, that sounds good to me.  Thanks,

Marek

Reply via email to