Skip to content

Uninitialized value when copying QSharedPointer with structured binding #42387

@jhasse

Description

@jhasse
Bugzilla Link 43042
Version unspecified
OS All
CC @devincoughlin,@haoNoQ

Extended Description

The following example code:

#include

QPair<int, QSharedPointer> 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>'
}
^
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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions