This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15085] New: Feature Request: Uninitialized Object Field Warning
- From: "emase at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Apr 2004 00:58:24 -0000
- Subject: [Bug c++/15085] New: Feature Request: Uninitialized Object Field Warning
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I noticed that gcc will issue a warning if a local variable is used without
being initialized, like so:
int count;
count += 1; // makes a compiler warning
But if you do the same for C++ objects, gcc will let it pass (to often
disasterous results.)
class Counter
{
Counter() { /* do nothing */ }
int my_count;
AddOne() { my_count += 1; } // correct, but meaningless without initialization
};
I imagine a warning checker which would check constructors to see if the
constructor initialized each field of the object and spit out a warning for
each uninitialized one.
--
Summary: Feature Request: Uninitialized Object Field Warning
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: emase at hotmail dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15085