This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/19808] miss a warning about uninitialized members in constructor
- From: "jason at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 29 Sep 2014 13:06:06 +0000
- Subject: [Bug c++/19808] miss a warning about uninitialized members in constructor
- Auto-submitted: auto-generated
- References: <bug-19808-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19808
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #22 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Manuel LÃpez-IbÃÃez from comment #21)
> I just got hit by this bug. This can obviously be warned in the FE as clang
> does:
>
> test.cc:4:11: warning: field 'j' is uninitialized when used here
> [-Wuninitialized]
> S() : i(j), j(1) {}
> ^
>
> simply by marking the members somehow as initialized or not, and when using
> them realizing that they are still uninitialized.
>
> Marek, Paolo, Jason? Any idea how to do this?
It could be done specifically for uses in mem-initializers by walking the
initializer in perform_mem_init to look for any references to members that
haven't been marked yet.
A more general warning that would cover, say,
X x;
x.x = x.y;
would need support in the existing back end -Wuninitialized code.