<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Uninitialized value when copying QSharedPointer with structured binding"
   href="https://bugs.llvm.org/show_bug.cgi?id=43042">43042</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Uninitialized value when copying QSharedPointer with structured binding
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dcoughlin@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jhasse@bixense.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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: <a href="https://bugreports.qt.io/browse/QTBUG-77641">https://bugreports.qt.io/browse/QTBUG-77641</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>