[R-pkg-devel] building on CRAN: GCC 12 truncation warning, attempted fix not working

Gillian Sharer g||||@n @end|ng |rom |r|@@w@@h|ngton@edu
Wed Mar 23 23:04:56 CET 2022


We have some C code in our IRISSeismic package that has starting generating truncation warnings with GCC 12. 

This is the original code and warning: 


char seqnum[7]; 

snprintf (seqnum, 7, "%06d", msr->sequence_number); 




warning: ' %06d' directive output may be truncated writing between 6 and 11 bytes into a region of size 7 [-Wformat-truncation=] 




This was our attempted fix and new warning: 

char seqnum[11]; 

snprintf (seqnum, sizeof(seqnum), "%06d", msr->sequence_number); 




warning: ' snprintf' output may be truncated before the last format character [-Wformat-truncation=] 




I don't have much experience with C and I'm not sure why the attempted fix didn't work. Does anyone have advice on what else I can try to fix this? 





Thanks, 

Gillian Sharer 

IRIS DMC 



	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list