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]

c++/4795: typeid does not output the class name properly in a nested class



>Number:         4795
>Category:       c++
>Synopsis:       typeid does not output the class name properly in a nested class
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 05 19:06:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     R. Seshadri
>Release:        2.95.3
>Organization:
>Environment:
NT workstation 4.0, PII based PC
>Description:
//: C09:RTTIandNesting.cpp
//{L} ../TestSuite/Test
#include <iostream>
#include <typeinfo>
using namespace std;

class One {
  class Nested {};
  Nested* n;
public:
  One() : n(new Nested) {}
  ~One() { delete n; }
  Nested* nested() { return n; }
};

int main() {
  One o;
  cout << typeid(*o.nested()).name() << endl;
} ///:~


When the above code (from Thinking in C++, Vol-2) is
compiled and linked as:

gxx -o n.exe RTTIandNesting.cpp

the output produced by n.exe is:

Q23One6Nested

The result is same in RedHat Linux 7.0 when I used egcs
and gcc, both are of versions 2.96 running on a PII-300

Sesh
>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]