This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/9014: unnamed classes cannot have base classes
- From: martin at xemacs dot org
- To: gcc-gnats at gcc dot gnu dot org
- Date: 20 Dec 2002 03:53:16 -0000
- Subject: c++/9014: unnamed classes cannot have base classes
- Reply-to: martin at xemacs dot org
>Number: 9014
>Category: c++
>Synopsis: unnamed classes cannot have base classes
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Thu Dec 19 19:56:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: martin@xemacs.org
>Release: gcc-3.2.1
>Organization:
>Environment:
Linux x86
>Description:
C++ classes can be unnamed.
C++ classes can have base classes.
Orthogonality suggests they can do both.
The following should compile (and indeed does under
Intel's icc and Comeau C++'s test drive):
class A {};
class {} x; // OK
class B : public A {} y; // OK
class : public A {} z; // parse error
(martin@wobble) ~/src/toy $ gcc -c unnamed-inheritor.cc
unnamed-inheritor.cc:4: parse error before `:' token
unnamed-inheritor.cc:4: ISO C++ forbids declaration of `z' with no type
This grammar production
class-head:
class-key identifieropt base-clauseopt
suggests that both the class name and the base clause are
independently optional.
>How-To-Repeat:
See description
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: