This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/15085] New: Feature Request: Uninitialized Object Field Warning


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]