This is the mail archive of the gcc-prs@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]

c++/924: -Wuninitialized does not seem to warn on uninitialize class members.



>Number:         924
>Category:       c++
>Synopsis:       -Wuninitialized does not seem to warn on uninitialize class members.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 29 02:26:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     mdejong@redhat.com
>Release:        CVS gcc as of Wed Nov 29 2000, all earlier releases
>Organization:
>Environment:
Linux (Red Hat 6.2)
>Description:
I would think that the following uninitialize
memory would get noticed by g++. I get
no warnings, even when I pass the -Wall
and -Wuninitialized flags.

class no_init {
    private:
    int num;
    char *ptr;

    public:
    no_init(): num(0) {

    }

    ~no_init() {
        delete [] ptr; // This memory is never initialized!
    }
};

int main() {
  no_init();
}

% g++ -static -o noinit -g -Wall -O2 -Wuninitialized no_init.cpp

% ./noinit
Segmentation fault (core dumped)
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:

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