[LLVMbugs] [Bug 13127] New: False warning about uninitialized field [-Wuninitialized] when calling static methods

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jun 16 12:40:59 PDT 2012


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

             Bug #: 13127
           Summary: False warning about uninitialized field
                    [-Wuninitialized] when calling static methods
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: tobias.hunger at gmx.de
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


I get a lot of warnings when building Qt code with a current (revision 158529
if I read my git log output correctly) clang compiler.

<<< snip >>>
../../../../qt4/include/QtCore/../../../../src/qt4/src/corelib/tools/qsharedpointer_impl.h:595:43:
warning: field is uninitialized when used here [-Wuninitialized]
    inline QWeakPointer(X *ptr) : d(ptr ? d->getAndRef(ptr) : 0), value(ptr)
                                          ^
1 warning generated.

At first glance the warning is correct, but d is defined as this:

Data d;

The struct data has a static methed getAndRef(ptrType).

So d->getAndRef(ptr) is calling a static method which admittedly is a unusual
way to write this, but AFAIK it is legal to do so.

The warnings go away when changing qsharedpointer_impl.h to read:
inline QWeakPointer(X *ptr) : d(ptr ? Data::getAndRef(ptr) : 0), value(ptr)

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