[LLVMbugs] [Bug 9522] New: Assignment to nested structs not marking fields as initialized

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 21 10:13:31 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=9522

           Summary: Assignment to nested structs not marking fields as
                    initialized
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: tjw at omnigroup.com
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=6351)
 --> (http://llvm.org/bugs/attachment.cgi?id=6351)
example

After updating my local build (to r128001), I'm getting spurious warnings about
uninitialized struct fields.

Two examples;

>From the minizip library in zipOpen2:


    if (pzlib_filefunc_def==NULL)
        fill_fopen_filefunc(&ziinit.z_filefunc);
    else
        ziinit.z_filefunc = *pzlib_filefunc_def;

    ziinit.filestream = (*(ziinit.z_filefunc.zopen_file))
                 (ziinit.z_filefunc.opaque,
                  pathname,
                  (append == APPEND_STATUS_CREATE) ?
                  (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE |
ZLIB_FILEFUNC_MODE_CREATE) :
                    (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE |
ZLIB_FILEFUNC_MODE_EXISTING));

a warning is produced about ziinit.z_filefunc.zopen_file not being initialized,
even though it was passed as a non-const pointer to fill_fopen_filefunc or
directly filled in the else clause.

Other simpler code hits the same issue, but this may be a slightly different
cause:

        CGRect integralFrame;
        integralFrame.origin.x = floor(frame.origin.x);
        integralFrame.origin.y = floor(frame.origin.y);
        integralFrame.size = frame.size;
        frame = CGRectIntegral(integralFrame);

Example attached for the second case.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list