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]]

______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to