On Tue, Sep 28, 2021 at 01:25:13PM -0400, Patrick Palka via Gcc-patches wrote: > On Tue, 28 Sep 2021, Jakub Jelinek wrote: > > > On Tue, Sep 28, 2021 at 06:49:38PM +0200, Jakub Jelinek via Gcc-patches > > wrote: > > > On Tue, Sep 28, 2021 at 12:44:58PM -0400, Patrick Palka wrote: > > > > Ah yeah, sorry for the noise, I misunderstood the function comment. > > > > > > > > On a related note I think 'ctx' can also be a NAMESPACE_DECL here in > > > > the case of a defaulted non-member operator<=> (as in the below), for > > > > which I'd expect the added COMPLETE_TYPE_P check to crash, but it looks > > > > like in this case DECL_INITIAL is error_mark_node instead of NULL_TREE > > > > so a crash is averted. If anyone else was wondering... > > > > > > > > struct A { > > > > friend constexpr bool operator==(const A&, const A&); > > > > }; > > > > > > > > constexpr bool operator==(const A&, const A&) = default; > > > > > > That means maybe ctx isn't the right way to get at the type and we > > > should look it up from the first argument's type? > > > I guess I'll look at where the build_comparison_op takes it from... > > I suspect this synthesize_method call from defaulted_late_check is > really only needed when operator<=> has been defaulted inside the class > definition, because out-of-class defaulted definitions generally already > get eagerly synthesized IIUC. So it might be fine to keep using ctx if > we also check DECL_DEFAULTED_IN_CLASS_P in defaulted_late_check. But > Jason knows for sure..
Indeed, cp_finish_decl has: 8333 /* An out-of-class default definition is defined at 8334 the point where it is explicitly defaulted. */ 8335 if (DECL_DELETED_FN (decl)) 8336 maybe_explain_implicit_delete (decl); 8337 else if (DECL_INITIAL (decl) == error_mark_node) 8338 synthesize_method (decl); Jakub