Re: Failures with gcd functions with GCC snapshots GCC and -O3 (?)

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема Re: Failures with gcd functions with GCC snapshots GCC and -O3 (?)
Дата
Msg-id CAEZATCUXVvq_TMyQOeaJKkJt=8oUmACqDHq13p7qL-_ncKH09A@mail.gmail.com
обсуждение исходный текст
Ответ на Failures with gcd functions with GCC snapshots GCC and -O3 (?)  (Michael Paquier <michael@paquier.xyz>)
Список pgsql-hackers
On Thu, 3 Jun 2021 at 08:26, Michael Paquier <michael@paquier.xyz> wrote:
>
> Hi all,
>
> serinus has been complaining about the new gcd functions in 13~:
> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=serinus&dt=2021-06-03%2003%3A44%3A14
>
> The overflow detection is going wrong the way up and down, like here:
>  SELECT gcd((-9223372036854775808)::int8, (-9223372036854775808)::int8); -- overflow
> -ERROR:  bigint out of range
> +         gcd
> +----------------------
> + -9223372036854775808
> +(1 row)
>
> That seems like a compiler bug to me as this host uses recent GCC
> snapshots, and I cannot see a problem in GCC 10.2 on my own dev box.
> But perhaps I am missing something?
>

Huh, yeah. The code is pretty clear that that should throw an error:

    if (arg1 == PG_INT64_MIN)
    {
        if (arg2 == 0 || arg2 == PG_INT64_MIN)
            ereport(ERROR,
                    (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
                     errmsg("bigint out of range")));

and FWIW it works OK on my dev box with gcc 10.2.1 and the same cflags.

Regards,
Dean



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Failures with gcd functions with GCC snapshots GCC and -O3 (?)
Следующее
От: Sergei Kornilov
Дата:
Сообщение: Re: Failures with gcd functions with GCC snapshots GCC and -O3 (?)