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));



Reply via email to