Re: warning: dereferencing type-punned pointer

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Tatsuo Ishii <ishii(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: warning: dereferencing type-punned pointer
Date: 2024-07-24 17:48:08
Message-ID: 1251525.1721843288@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter(at)eisentraut(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2024-07-24 17:53:47 Re: warning: dereferencing type-punned pointer
Previous Message Jeff Davis 2024-07-24 17:45:31 Re: [18] Policy on IMMUTABLE functions and Unicode updates