[PATCH] D135088: [Clang] make canonical AutoType constraints-free
Matheus Izvekov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 3 17:31:48 PDT 2022
mizvekov added inline comments.
================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:8664-8668
+ if (QualType RT = FD->getDeclaredReturnType();
+ DCK == DefaultedComparisonKind::ThreeWay &&
+ RT->getContainedDeducedType() &&
+ (!Context.hasSameType(RT, Context.getAutoDeductType()) ||
+ RT->getContainedAutoType()->isConstrained())) {
----------------
ychen wrote:
> mizvekov wrote:
> > I think this might crash if the three-way comparison is defaulted with a deduced template specialization.
> >
> > Something like:
> > ```
> > template <class> struct A {};
> >
> > struct P {
> > friend A operator<=>(const P&, const P&) = default;
> > };
> > ```
> >
> > The problem is that `RT->getContainedDeducedType()` will return non-null, because DTSTs are also deduced types, but `RT->getContainedAutoType()` will return null, because DTSTs are not AutoTypes.
> > I think this might crash if the three-way comparison is defaulted with a deduced template specialization.
> > The problem is that `RT->getContainedDeducedType()` will return non-null, because DTSTs are also deduced types, but `RT->getContainedAutoType()` will return null, because DTSTs are not AutoTypes.
>
> `RT->getContainedAutoType()` will be called only when `RT` is `AutoType`?
Oh right, I see it now, there is a lot going on in that condition :)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135088/new/
https://reviews.llvm.org/D135088
More information about the cfe-commits
mailing list