Strange Warning COPY_UNINIT_PTR

LegacyForumLegacyForum Posts: 1,664 ✭✭
edited December 2016 in Insure++
Using strerror(errno) in printf gives Warning

we get a COPY_UNINIT_PTR warning for this piece of code:

dprintf( ERRORS, "IDM -- Cannot create message queue [%s]. File %s. Key=%d\n", strerror(errno), datafile, msgkey );
The warning says:
Copying uninitialized pointer: strerror(*__errno_location())

Stack trace where the error occurred:
RCVINFO::Initialize(const char *, int, const char *) ../, 626
main() ../, 3894

The signature of strerror is
extern char *strerror (int __errnum) __THROW;
and errno is defined as
extern int *__errno_location (void) __THROW __attribute__ ((__const__)); # define errno (*__errno_location ())
I expect the returns of glibc functions to be initialized and watching my log file, the dprintf is executed correctly.
Is Insure++ mistaken here or am I ?

Here is what we use:

Architekture x86
Compileer gcc 3.3.3
Insure++ Ver. 7.1.1

Any help is appreciated!



  • LegacyForumLegacyForum Posts: 1,664 ✭✭

    Insure++ "scribbles" a known bit-pattern into memory locations; thus if memory remains uninitialized, it will contain the known bit-pattern. Therefore, COPY_UNINIT_PTR can only produce a false-positive if the actual pointer value is the same as the known bit-pattern.

    It's also possible that this is the first call to: errno_location(), thus the cached pointer isn't yet initialized, (and it becomes initialized after the call).

Sign In or Register to comment.