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++/11112] New: wrong warning when classes have private destructors and their first member functions are not static.


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.


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