c++/9165: [3.3/3.4 regression] false "defined but not used" warnings

jbuck@synopsys.com jbuck@synopsys.com
Sat Jan 4 00:16:00 GMT 2003


>Number:         9165
>Category:       c++
>Synopsis:       [3.3/3.4 regression] false "defined but not used" warnings
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 03 16:16:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Joe Buck
>Release:        3.3-pre, 3.4-experimental
>Organization:
>Environment:
GNU/Linux i686 (though probably all)
>Description:
gcc 3.3-pre and 3.4-experimental issue "defined but not used"
warnings for static class objects whose destructors do cleanup operations.  This is a more dangerous regression than it may appear, because it may inspire programmers to remove needed code from their applications, resulting in leaks and other failures.  This is especially likely in shops that ask for clean -Wall compiles.

This problem is not in gcc 3.2.1 or earlier versions.
>How-To-Repeat:
Compile with "gcc -c -O -Wall cleanup.cxx" where cleanup.cxx is
------------------------------
void do_cleanups();

class Cleanup {
public:
    ~Cleanup() { do_cleanups();}
};

static Cleanup dummy;
---------------------------------

and get

cleanup.cpp:8: warning: `Cleanup dummy' defined but not used
>Fix:

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



More information about the Gcc-bugs mailing list