r-lib / bit64

An R package with an S3 Class for Vectors of 64bit Integers
32 stars 8 forks source link

Compile warning on winbuilder #110

Closed MichaelChirico closed 1 month ago

MichaelChirico commented 1 month ago
integer64.c: In function 'runif_integer64':
integer64.c:1015:15: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 1015 |     while( (*((long long *) &ii)) == NA_INTEGER64){
      |              ~^~~~~~~~~~~~~~~~~~
integer64.c:1023:36: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 1023 |     ret[i] = min + ( (long long)(*((unsigned long long *)(&ii))) % d);
      |                                   ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

https://win-builder.r-project.org/Y2yv92Drbtjt/00install.out

MichaelChirico commented 1 month ago

There is a disabler for this warning:

https://github.com/r-lib/bit64/blob/a64a059a63433dbfff3cad55822f0c42df3db76c/src/integer64.c#L1013-L1016

However it was commented out intentionally here: 93e372e1b9f915a37698f581c22e4bf224071814

Not sure why, seems pretty harmless to keep it there. Maybe we can put a guard in (per Gemini): #if defined(__GNUC__)

MichaelChirico commented 1 month ago

Confirmed it's gone away:

https://win-builder.r-project.org/7wrJ3BeNVCQW/00install.out