Re: gcc versus division-by-zero traps - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: gcc versus division-by-zero traps
Date
Msg-id 200909172221.n8HMLUX13580@momjian.us
Whole thread Raw
In response to gcc versus division-by-zero traps  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> I hope that the bug will get fixed in due course, but even if they
> respond pretty quickly it will be years before the problem disappears
> from every copy of gcc in the field.  So I'm thinking that it would
> behoove us to install a workaround, now that we've characterized the
> problem sufficiently.  What I am thinking is that in the three
> functions known to exhibit the bug (int24div, int28div, int48div)
> we should do something like this:
> 
> 
>     if (arg2 == 0)
> +    {
>         ereport(ERROR,
>                 (errcode(ERRCODE_DIVISION_BY_ZERO),
>                  errmsg("division by zero")));
> +        /* ensure compiler realizes we don't reach the division */
> +        PG_RETURN_NULL();
> +    }

Could we document this a little better, perhaps refer to a file
somewhere or a central comment on its purpose?

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


pgsql-hackers by date:

Previous
From: Dan Colish
Date:
Subject: Re: generic copy options
Next
From: Dan Colish
Date:
Subject: Re: [PATCH] pgbench: new feature allowing to launch shell commands