[llvm-bugs] [Bug 43042] New: Uninitialized value when copying QSharedPointer with structured binding

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 19 01:18:18 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43042

            Bug ID: 43042
           Summary: Uninitialized value when copying QSharedPointer with
                    structured binding
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: dcoughlin at apple.com
          Reporter: jhasse at bixense.com
                CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org

The following example code:


#include <QSharedPointer>

QPair<int, QSharedPointer<int>> foo() {
        return {42, nullptr};
}

int main() {
        auto [x, p] = foo();
        auto p2 = p;
}


produces the following warning:


QtCore.framework/Headers/qsharedpointer_impl.h:460:7: warning: 1st function
call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
    { deref(d); }
      ^
test.cpp:9:12: note: Uninitialized value stored to '.second.d'
        auto p2 = p;
                  ^
test.cpp:10:1: note: Calling implicit destructor for 'QPair<int,
QSharedPointer<int>>'
}
^
test.cpp:10:1: note: Calling '~QSharedPointer'
QtCore.framework/Headers/qsharedpointer_impl.h:315:25: note: Calling
'QSharedPointer::deref'
    ~QSharedPointer() { deref(); }
                        ^
QtCore.framework/Headers/qsharedpointer_impl.h:460:7: note: 1st function call
argument is an uninitialized value
    { deref(d); }
      ^


Which is weird, since QSharedPointer's copy constructor initializes d. Is this
a false-positive?

See related Qt bug report: https://bugreports.qt.io/browse/QTBUG-77641

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190819/9d46798e/attachment-0001.html>


More information about the llvm-bugs mailing list