Re: pgsql: Provide overflow safe integer math inline functions.

Michael Paquier <michael.paquier@gmail.com>

From: Michael Paquier <michael.paquier@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-committers@postgresql.org
Date: 2017-12-17T07:00:31Z
Lists: pgsql-hackers
On Sun, Dec 17, 2017 at 9:32 AM, Andres Freund <andres@anarazel.de> wrote:
> I've since tried this via the buildfarm, but still:
>
> configure:14480: checking for __builtin_mul_overflow
> configure:14500: ccache clang -o conftest -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -g -O2  -D_GNU_SOURCE  -I/usr/include/et   conftest.c -lssl -lcrypto -lz -lreadline -lrt -lcrypt -ldl -lm  >&5
> configure:14500: $? = 0
> configure:14508: result: yes
>
> I'm not quite following. Could you check if the same happens without
> -O2? Not because that'd be a solution, but to narrow down how this
> happens?

I have triggered a new test manually this morning on dangomushi
because I knew that it would fail as I have tested as well stuff
similar to the version you have pushed. Please note that if you added
a volatile cast to "result" as well, then compilation was able to
complete and regression tests passed...
-- 
Michael


Commits

  1. Try harder to detect unavailability of __builtin_mul_overflow(int64).

  2. Try to detect runtime unavailability of __builtin_mul_overflow(int64).

  3. Fix a number of copy & paste comment errors in common/int.h.

  4. Provide overflow safe integer math inline functions.