Re: warning: dereferencing type-punned pointer
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: Tatsuo Ishii <ishii@postgresql.org>, pgsql-hackers@postgresql.org
Date: 2024-07-24T17:41:13Z
Lists: pgsql-hackers
On 24.07.24 08:55, Tatsuo Ishii wrote: > origin.c: In function ‘StartupReplicationOrigin’: > origin.c:773:16: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] > 773 | file_crc = *(pg_crc32c *) &disk_state; > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > I am not so sure about StartupReplicationOrigin. Should we fix it now? > For me the code looks sane as long as we keep -fno-strict-aliasing > option. Or maybe better to fix so that someday we could remove the > compiler option? 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));
Commits
-
Fix a strict aliasing violation
- 2fcc5a715130 19 (unreleased) landed
-
Add input function for data type pg_ndistinct
- 44eba8f06e55 19 (unreleased) cited