public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107290] New: False positive -Wuninitialized with Eigen
@ 2022-10-17 10:20 carlosgalvezp at gmail dot com
2022-10-17 11:22 ` [Bug c++/107290] " rguenth at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: carlosgalvezp at gmail dot com @ 2022-10-17 10:20 UTC (permalink / raw)
To: gcc-bugs
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)) {}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/107290] False positive -Wuninitialized with Eigen
2022-10-17 10:20 [Bug c++/107290] New: False positive -Wuninitialized with Eigen carlosgalvezp at gmail dot com
@ 2022-10-17 11:22 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-17 11:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107290
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |24639
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-10-17
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I can confirm the diagnostics at -O{1,2,3}. We diagnose the aggregate copy
in
<bb 2> [local count: 1073741824]:
MEM[(struct plain_array *)&p] ={v} {CLOBBER};
MEM[(struct DenseStorage *)&D.103583] ={v} {CLOBBER};
MEM[(struct DenseStorage *)&D.103583].m_data = MEM[(const struct DenseStorage
&)&p].m_data;
Foo::Foo (&Foo, &D.103583);
D.103583 ={v} {CLOBBER(eol)};
p ={v} {CLOBBER(eol)};
Foo ={v} {CLOBBER(eol)};
return;
clearly 'p' is completely uninitialized and we copy m_data from it to
the value argument of Foo::Foo.
'p' gets initialized by
struct Points p;
<<cleanup_point <<< Unknown tree: expr_stmt
Eigen::Array<float, 3, 1>::Array (&p) >>>>>;
I don't know enough C++ to decipher what supposedly initializes m_data.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
[Bug 24639] [meta-bug] bug to track all Wuninitialized issues
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-17 11:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-17 10:20 [Bug c++/107290] New: False positive -Wuninitialized with Eigen carlosgalvezp at gmail dot com
2022-10-17 11:22 ` [Bug c++/107290] " rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).