public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111090] New: Bogus -Wuninitialized for trivial copy of nested struct with partially initialized array
@ 2023-08-21 16:18 ed at catmur dot uk
2023-08-21 16:18 ` [Bug c++/111090] " ed at catmur dot uk
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: ed at catmur dot uk @ 2023-08-21 16:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111090
Bug ID: 111090
Summary: Bogus -Wuninitialized for trivial copy of nested
struct with partially initialized array
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ed at catmur dot uk
Target Milestone: ---
struct A {
A() { buf[0] = 0; }
int buf[2];
};
struct B { A a; };
struct C {
C(B const& b) : b(b) {}
B b;
};
struct D {
D(C c) : c(c) {}
C c;
};
D f() { return D(C(B())); }
In constructor 'C::C(const B&)',
inlined from 'D f()' at <source>:14:16:
<source>:7:21: warning: '<unnamed>.B::a.A::a[1]' is used uninitialized
[-Wuninitialized]
7 | C(B const& b) : b(b) {}
| ^~~~
<source>: In function 'D f()':
<source>:14:22: note: '<anonymous>' declared here
14 | D f() { return D(C(B())); }
| ^
This appears to have started in 7.1.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/111090] Bogus -Wuninitialized for trivial copy of nested struct with partially initialized array
2023-08-21 16:18 [Bug c++/111090] New: Bogus -Wuninitialized for trivial copy of nested struct with partially initialized array ed at catmur dot uk
@ 2023-08-21 16:18 ` ed at catmur dot uk
2023-08-21 16:27 ` [Bug tree-optimization/111090] " pinskia at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: ed at catmur dot uk @ 2023-08-21 16:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111090
--- Comment #1 from Ed Catmur <ed at catmur dot uk> ---
uh, -O -Wall is necessary, obviously. https://godbolt.org/z/eT9dY467P
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/111090] Bogus -Wuninitialized for trivial copy of nested struct with partially initialized array
2023-08-21 16:18 [Bug c++/111090] New: Bogus -Wuninitialized for trivial copy of nested struct with partially initialized array ed at catmur dot uk
2023-08-21 16:18 ` [Bug c++/111090] " ed at catmur dot uk
@ 2023-08-21 16:27 ` pinskia at gcc dot gnu.org
2023-08-21 16:30 ` pinskia at gcc dot gnu.org
2023-08-21 17:01 ` ed at catmur dot uk
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-21 16:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111090
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I don't see how it is bogus as you admit it was only partially initialized
even. The act of copying is still an use IIRC.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/111090] Bogus -Wuninitialized for trivial copy of nested struct with partially initialized array
2023-08-21 16:18 [Bug c++/111090] New: Bogus -Wuninitialized for trivial copy of nested struct with partially initialized array ed at catmur dot uk
2023-08-21 16:18 ` [Bug c++/111090] " ed at catmur dot uk
2023-08-21 16:27 ` [Bug tree-optimization/111090] " pinskia at gcc dot gnu.org
@ 2023-08-21 16:30 ` pinskia at gcc dot gnu.org
2023-08-21 17:01 ` ed at catmur dot uk
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-21 16:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111090
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced to make it obvious what is going on:
```
struct A {
A() { buf[0] = 0; }
int buf[2];
};
A g()
{
A a;
A b = a;
return b;
}
```
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/111090] Bogus -Wuninitialized for trivial copy of nested struct with partially initialized array
2023-08-21 16:18 [Bug c++/111090] New: Bogus -Wuninitialized for trivial copy of nested struct with partially initialized array ed at catmur dot uk
` (2 preceding siblings ...)
2023-08-21 16:30 ` pinskia at gcc dot gnu.org
@ 2023-08-21 17:01 ` ed at catmur dot uk
3 siblings, 0 replies; 5+ messages in thread
From: ed at catmur dot uk @ 2023-08-21 17:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111090
Ed Catmur <ed at catmur dot uk> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #4 from Ed Catmur <ed at catmur dot uk> ---
(In reply to Andrew Pinski from comment #2)
> I don't see how it is bogus as you admit it was only partially initialized
> even. The act of copying is still an use IIRC.
Sorry, my bad. I reduced it past the point of usefulness and got myself
confused. Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-08-21 17:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-21 16:18 [Bug c++/111090] New: Bogus -Wuninitialized for trivial copy of nested struct with partially initialized array ed at catmur dot uk
2023-08-21 16:18 ` [Bug c++/111090] " ed at catmur dot uk
2023-08-21 16:27 ` [Bug tree-optimization/111090] " pinskia at gcc dot gnu.org
2023-08-21 16:30 ` pinskia at gcc dot gnu.org
2023-08-21 17:01 ` ed at catmur dot uk
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).