Skip to content

LGTM.com - false positive in C++ code #ifdef'd out #3840

@jimis

Description

@jimis

I got the alert "Call to localtime is potentially dangerous", but the code annotated is inside an ifdef, and it shouldn't be included on the usual platforms.

The code in a nutshell:

#if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
    localtime_r();
#else
    localtime();
    // LGTM.COM WARNING: Call to localtime is potentially dangerous
#endif

I have verified that configuring and compiling on Ubuntu Linux calls the re-entrant function. The mere existence of the non-reentrant fallback shouldn't cause a warning.

Link to the original warning

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions