UnifyFS icon indicating copy to clipboard operation
UnifyFS copied to clipboard

Address --Wstrict-aliasing warnings for type-punning

Open nedbass opened this issue 7 years ago • 0 comments

There are a number of compiler warnings related to the use of type-punning to reinterpret the memory type of message buffers:

unifycr.c: In function ‘unifycr_get_global_fid’:
unifycr.c:942:5: warning: dereferencing type-punned pointer will break
strict-aliasing rules [-Wstrict-aliasing]
     *gfid = *((int *)md);
     ^

This is considered unsafe as it can lead to bugs at compiler higher optimization levels. PR #69 proposes to disable those warnings until a proper fix can be implemented. Perhaps those buffers should be represented by structs or unions rather than raw byte arrays.

nedbass avatar Jan 03 '18 01:01 nedbass