Re: pg_verify_checksums and -fno-strict-aliasing - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: pg_verify_checksums and -fno-strict-aliasing
Date
Msg-id alpine.DEB.2.21.1808301325070.32764@lancre
Whole thread Raw
In response to pg_verify_checksums and -fno-strict-aliasing  (Michael Banck <michael.banck@credativ.de>)
Responses Re: pg_verify_checksums and -fno-strict-aliasing
Re: pg_verify_checksums and -fno-strict-aliasing
List pgsql-hackers
> I noticed that pg_verify_checksums computes bogus checksums if I compile
> it with '-O2 -Wall' but without -fno-strict-aliasing. Also I am getting
> a compile warning then:
>
> [...]
>
> If I add -fno-strict-aliasing to $CFLAGS, the problem goes away.
>
> Is this something to worry about, or just pilot error cause I am not
> using the same $CFLAGS as for the rest of the build? I originally
> noticed this problem with my external fork of pg_verify_checksums.

It looks like the code is using aliasing where the standard says it should 
not, which breaks compiler optimization, and the added options tells the 
compiler to not assume that the code conforms to the standard...

As PostgreSQL source is expected to conform to some C standard (unsure 
which one right now, possibly c89 but maybe it is beginning to switch to 
c99, a young 19 years old standard), I'd suggest that the right fix is 
rather to actually remove the aliasing issue.

-- 
Fabien.


pgsql-hackers by date:

Previous
From: Etsuro Fujita
Date:
Subject: Re: Expression errors with "FOR UPDATE" and postgres_fdw with partitionwise join enabled.
Next
From: Amit Kapila
Date:
Subject: Re: pg_verify_checksums failure with hash indexes