[Bug c++/107290] New: False positive -Wuninitialized with Eigen
carlosgalvezp at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Oct 17 10:20:15 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107290
Bug ID: 107290
Summary: False positive -Wuninitialized with Eigen
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: carlosgalvezp at gmail dot com
Target Milestone: ---
Created attachment 53713
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53713&action=edit
Preprocessed source
Hi,
I'm getting a false positive in the following code (preprocessed attached):
#include <Eigen/Core>
using Points = Eigen::Array<float, 3, 1>;
struct Foo
{
explicit Foo(Points p);
Points p_{};
};
void foo()
{
Points p{};
Foo Foo(p);
}
Compiling with flags:
-std=c++14 -Wall -Wextra -O3
In file included from /opt/compiler-explorer/libs/eigen/v3.3.7/Eigen/Core:450,
from <source>:1:
In copy constructor 'Eigen::DenseStorage<T, Size, _Rows, _Cols,
_Options>::DenseStorage(const Eigen::DenseStorage<T, Size, _Rows, _Cols,
_Options>&) [with T = float; int Size = 3; int _Rows = 3; int _Cols = 1; int
_Options = 0]',
inlined from 'Eigen::PlainObjectBase<Derived>::PlainObjectBase(const
Eigen::PlainObjectBase<Derived>&) [with Derived = Eigen::Array<float, 3, 1>]'
at
/opt/compiler-explorer/libs/eigen/v3.3.7/Eigen/src/Core/PlainObjectBase.h:520:17,
inlined from 'Eigen::Array<_Scalar, _Rows, _Cols, _Options, _MaxRows,
_MaxCols>::Array(const Eigen::Array<_Scalar, _Rows, _Cols, _Options, _MaxRows,
_MaxCols>&) [with _Scalar = float; int _Rows = 3; int _Cols = 1; int _Options =
0; int _MaxRows = 3; int _MaxCols = 1]' at
/opt/compiler-explorer/libs/eigen/v3.3.7/Eigen/src/Core/Array.h:229:25,
inlined from 'void foo()' at <source>:14:14:
/opt/compiler-explorer/libs/eigen/v3.3.7/Eigen/src/Core/DenseStorage.h:194:47:
warning: 'p.Eigen::Array<float, 3, 1, 0, 3,
1>::<unnamed>.Eigen::PlainObjectBase<Eigen::Array<float, 3, 1, 0, 3, 1>
>::m_storage.Eigen::DenseStorage<float, 3, 3, 1, 0>::m_data' is used
uninitialized [-Wuninitialized]
194 | DenseStorage(const DenseStorage& other) : m_data(other.m_data) {
| ^~~~~~~~~~~~~~~~~~~~
<source>: In function 'void foo()':
<source>:13:12: note: 'p' declared here
13 | Points p{};
| ^
Repro on Godbolt: https://godbolt.org/z/TaTdT33vr
Interestingly, if I define the constructor inline, then the warning disappears:
- explicit Foo(Points p);
+ explicit Foo(Points p) : p_(std::move(p)) {}
More information about the Gcc-bugs
mailing list