[Bug c++/11112] New: wrong warning when classes have private destructors and their first member functions are not static.

grivet@labri.fr gcc-bugzilla@gcc.gnu.org
Fri Jun 6 17:07:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11112

           Summary: wrong warning when classes have private destructors and
                    their first member functions are not static.
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: grivet@labri.fr
                CC: gcc-bugs@gcc.gnu.org

For instance:

class A {
  ~A() {}
public:
  void foo() {
  }
  static A *instance();
};

A *A::instance() {
  return new A;
}

int main() {
  return 0;
}

produces:
g++ -Wall -o test test.cpp
test.cpp:1: warning: `class A' only defines a private destructor and has no 
   friends

Whereas:

class A {
  ~A() {}
public:
  static A *instance(); // only the two member functions are inverted
  void foo() {
  }
};

A *A::instance() {
  return new A;
}

int main() {
  return 0;
}

produces no warning.



More information about the Gcc-bugs mailing list