Re: warning: dereferencing type-punned pointer

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: Tatsuo Ishii <ishii@postgresql.org>, pgsql-hackers@postgresql.org
Date: 2024-07-24T17:48:08Z
Lists: pgsql-hackers
Peter Eisentraut <peter@eisentraut.org> writes:
> This is basically the textbook example of aliasing violation, isn't it? 
> Wouldn't it be just as simple to do

> memcpy(&file_crc, &disk_state, sizeof(file_crc));

+1.  Also, it seems thoroughly bizarre to me that this case is handled
before checking for read failure.  I'd move the stanza to after the
"if (readBytes < 0)" one.

			regards, tom lane



Commits

  1. Fix a strict aliasing violation

  2. Add input function for data type pg_ndistinct