Re: fix for strict-alias warnings - Mailing list pgsql-patches

From Tom Lane
Subject Re: fix for strict-alias warnings
Date
Msg-id 6174.1066106240@sss.pgh.pa.us
Whole thread Raw
In response to Re: fix for strict-alias warnings  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-patches
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Tom Lane wrote:
>> I don't think we understand the dangers quite yet, and I think the
>> patches applied to date constitute useless thrashing rather than fixes.

> In reading http://www.gnu.org/software/gcc/bugs.html#nonbugs_c and the
> link it references,
> http://mail-index.netbsd.org/tech-kern/2003/08/11/0001.html, they seem
> to be talking about any pointer casting.

The latter reference makes it absolutely crystal-clear that inserting
void* casts does *not* fix the issue.  Also observe the statement

> gcc may warn for some constructs that break the aliasing rules, but not
> all of them (or not even most of them!), so a warning-free source code
> does not give you any guarantee.

I have to agree now with Andrew's last mail that -fno-strict-aliasing is
the only safe solution.  Since gcc isn't even pretending that it can
warn in all cases where the optimization might break things, I'm not
sure we could ever responsibly enable this optimization.  I do not feel
this is our problem; it is the compiler hackers' fault if they need to
make unsupportable, untestable assumptions about application code.

Basically, ISO broke the language here, and I say it's a screwup up with
which we need not put.

            regards, tom lane

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: fix for strict-alias warnings
Next
From: "Andrew Dunstan"
Date:
Subject: Re: fix for strict-alias warnings