Replace this call to the non reentrant function "gmtime"

Hello,

the support was not able to answer this question and asked me to post it here in this forum, maybe someone here is able to give the answer.

Every time if we use the function fmt::gmtime() in our c++ source, we get a code smell about to replace gmtime() by gmtime_r(). This would be correct if we are using the standard library implementation, but here we are using the fmt lib: API Reference — fmt dev documentation

Is this a bug? Or is there a way to adjust that?

Best regards

1 Like

Hi,

Welcome to the community!

Could you provide a reproducer? I.e. a contained code snippet that demonstrates the problem?

Also, which support are you referring to here?

 
Ann

Hello Ann, this is a typical example:

Hi @to-s ,

Thanks for raising this issue. It is indeed a bug that was identified. You can follow its progress in this ticket.

In the meantime, you can change the value of the setting S1912.nonReentrantFunctionList to avoid raising on localtime and gmtime. Its default value is:
asctime,crypt,ctermid,ctime,fgetgrent,fgetpwent,fgetspent,getgrent,getgrgid,getgrnam,gethostbyaddr,gethostbyname,gethostbyname2,gethostent,getlogin,getnetbyaddr,getnetbyname,getnetent,getnetgrent,getprotobyname,getprotobynumber,getprotoent,getpwent,getpwnam,getpwuid,getrpcbyname,getrpcbynumber,getrpcent,getservbyname,getservbyport,getservent,getspent,getspnam,gmtime,localtime,sgetspent,strtok,ttyname
You can change it to remove localtime and gmtime:
asctime,crypt,ctermid,ctime,fgetgrent,fgetpwent,fgetspent,getgrent,getgrgid,getgrnam,gethostbyaddr,gethostbyname,gethostbyname2,gethostent,getlogin,getnetbyaddr,getnetbyname,getnetent,getnetgrent,getprotobyname,getprotobynumber,getprotoent,getpwent,getpwnam,getpwuid,getrpcbyname,getrpcbynumber,getrpcent,getservbyname,getservbyport,getservent,getspent,getspnam,sgetspent,strtok,ttyname

I hope this helps.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.