public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/100126] New: missing -Wuninitialized using a trivial member of class with another nontrivial member
@ 2021-04-16 20:35 msebor at gcc dot gnu.org
2021-04-16 20:37 ` [Bug tree-optimization/100126] " msebor at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-16 20:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100126
Bug ID: 100126
Summary: missing -Wuninitialized using a trivial member of
class with another nontrivial member
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
Reading an uninitialized trivial member of a struct that contains a member of a
type with a user-defined (or similar) ctor is not diagnosed. The reason is
that the call to the ctor is (exceedingly) conservatively assumed to store into
the other members of the enclosing struct.
$ gcc -O1 -S -Wall -fdump-tree-uninit=/dev/stdout t.C
struct A
{
char *p;
A ();
};
struct B
{
int i;
A a;
};
void f ()
{
B b;
__builtin_printf ("%d\n", b.i); // missing -Wuninitialized
}
;; Function f (_Z1fv, funcdef_no=0, decl_uid=2365, cgraph_uid=4,
symbol_order=3)
void f ()
{
struct B b;
int _1;
<bb 2> [local count: 1073741824]:
A::A (&b.a); <<< assumed to set b.i
_1 = b.i;
__builtin_printf ("%d\n", _1); <<< missing -Wuninitialized
b ={v} {CLOBBER};
return;
}
This isn't C++ specific. The same limitation affects C:
struct A
{
char *p;
};
void init (struct A *);
struct B
{
int i;
struct A a;
};
void f ()
{
struct B b;
init (&b.a);
__builtin_printf ("%d\n", b.i);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/100126] missing -Wuninitialized using a trivial member of class with another nontrivial member
2021-04-16 20:35 [Bug tree-optimization/100126] New: missing -Wuninitialized using a trivial member of class with another nontrivial member msebor at gcc dot gnu.org
@ 2021-04-16 20:37 ` msebor at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-16 20:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100126
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=88175
Blocks| |24639
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The test case was derived from the one in pr88175 comment 16.
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:[~2021-04-16 20:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-16 20:35 [Bug tree-optimization/100126] New: missing -Wuninitialized using a trivial member of class with another nontrivial member msebor at gcc dot gnu.org
2021-04-16 20:37 ` [Bug tree-optimization/100126] " msebor 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).