This is the mail archive of the gcc-prs@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]

c++/9155: [3.4 regression] new parser rejects legal use of typeid(xxx).name()


>Number:         9155
>Category:       c++
>Synopsis:       [3.4 regression] new parser rejects legal use of typeid(xxx).name()
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 03 02:46:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Andrew Pollard
>Release:        gcc-3.4-20030102
>Organization:
>Environment:
i686-pc-linux-gnu/RedHat8.0 on a PIII
>Description:
The following code snippet gets an error when compiled with gcc-3.4-20030102

gcc-3.4-20021224 (pre-new parser) works...

typeid.cxx:
-------------------
#include <typeinfo>

struct A {
    virtual ~A() {}
};

void
foo(A* a)
{
    typeid(*a).name();
}

void
bar(A* a)
{
    const std::type_info& t = typeid(*a);
    t.name();
}
-------------------

% g++34 typeid.cxx
typeid.cxx: In function `void foo(A*)':
typeid.cxx:10: error: request for member `std::type_info::name() const' in `
   __cxa_bad_typeid()()', which is of non-class type `const std::type_info&'

Note how 'bar(A*)' compiles fine.

Is this a parser bug, or is this the standard mandated behaviour? (I'd guess a bug...)
>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]