On Mon, Jul 17, 2023 at 9:35 AM Tamar Christina <[email protected]> wrote:
>
> > On Mon, Jul 17, 2023 at 12:21 AM Tamar Christina via Gcc-patches <gcc-
> > [email protected]> wrote:
> > >
> > > > -----Original Message-----
> > > > From: Richard Biener <[email protected]>
> > > > Sent: Monday, July 17, 2023 7:19 AM
> > > > To: Roger Sayle <[email protected]>
> > > > Cc: [email protected]; Tamar Christina
> > > > <[email protected]>
> > > > Subject: Re: [PATCH] Fix bootstrap failure (with g++ 4.8.5) in tree-if-
> > conv.cc.
> > > >
> > > > On Fri, Jul 14, 2023 at 8:56 PM Roger Sayle
> > > > <[email protected]>
> > > > wrote:
> > > > >
> > > > >
> > > > >
> > > > > This patch fixes the bootstrap failure I'm seeing using gcc 4.8.5
> > > > > as
> > > > >
> > > > > the host compiler. Ok for mainline? [I might be missing
> > > > > something]
> > > >
> > > > OK. Btw, while I didn't spot this during review I would appreciate
> > > > if the code could use vec.[q]sort, this should work with a lambda as
> > > > well I think.
> > >
> > > That was my first use, but that hits
> > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99469
> >
> > That is not hitting PR 99469 but rather it means your comparison is not
> > correct for an (unstable) sort.
> > That is qsort comparator should have this relationship `f(a,b) == !f(b, a)`
> > and
> > `f(a,a)` should also return false.
>
> I'm using the standard std::pair comparator which indicates that f(a,a) is
> true,
> https://en.cppreference.com/w/cpp/utility/pair/operator_cmp
>
> > If you are running into this for qsort here, you will most likely run into
> > issues
> > with std::sort later on too.
>
> Don't see why or how. It needs to have a consistent relationship which
> std::pair
> maintains. So why would using the standard tuple comparator with a standard
> std::sort cause problem?
At least for
return left.second < right.second;
f(a,a) doesn't hold. Note qsort can end up comparing an element to
itself (not sure
if GCCs implementation now can).
Richard.
> Thanks,
> Tamar
>
> >
> > Thanks,
> > Andrew
> >
> > >
> > > Regards,
> > > Tamar