Re: Remove dependence on integer wrapping - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Remove dependence on integer wrapping
Date
Msg-id CAH2-Wzk-qpDABgvY3mS9=yB=XtoEbZcSPQsgoyczc6OAFOghnQ@mail.gmail.com
Whole thread Raw
In response to Re: Remove dependence on integer wrapping  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Mon, Jun 10, 2024 at 2:30 PM Andres Freund <andres@anarazel.de> wrote:
> On 2024-06-09 21:57:54 -0400, Tom Lane wrote:
> > BTW, while I approve of trying to get rid of our need for -fwrapv,
> > I'm quite scared of actually doing it.

IMV it's perfectly fine to defensively assume that we need -fwrapv,
even given a total lack of evidence that removing it would cause harm.
Doing it to "be more in line with the standard" is a terrible argument.

> I think that's a quite fair concern. One potentially relevant datapoint is
> that we actually don't have -fwrapv equivalent on all platforms, and I don't
> recall a lot of complaints from windows users.

That might just be because MSVC inherently doesn't do optimizations
that rely on signed wrap being undefined behavior. Last I checked MSVC
just doesn't rely on the standard's strict aliasing rules, even as an
opt-in thing.

> Of course it's quite possible
> that they'd never notice...

Removing -fwrapv is something that I see as a potential optimization.
It should be justified in about the same way as any other
optimization.

I suspect that it doesn't actually have any clear benefits for us. But
if I'm wrong about that then the benefit might still be achievable
through other means (something far short of just removing -fwrapv
globally).

> I think this is a good argument for enabling -ftrapv in development
> builds. That gives us at least a *chance* of seeing these issues.

+1. I'm definitely prepared to say that code that actively relies on
-fwrapv is broken code.


--
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Alexander Lakhin
Date:
Subject: Re: BF mamba failure
Next
From: Peter Geoghegan
Date:
Subject: Re: Revive num_dead_tuples column of pg_stat_progress_vacuum