Re: fix for strict-alias warnings

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PG Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: fix for strict-alias warnings
Date: 2003-10-14 04:37:20
Message-ID: 6174.1066106240@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2003-10-14 05:48:01 comments on casts
Previous Message Neil Conway 2003-10-14 04:28:14 Re: question about CURSOR

Browse pgsql-patches by date

  From Date Subject
Next Message mirko tebaldi 2003-10-14 10:26:55 Invio in corso posta elettronica: postgres-it.po.bz2
Previous Message Bruce Momjian 2003-10-14 00:31:56 Re: fix for strict-alias warnings