The following code fails to compile
struct A {
    virtual ~A() {}; //make A polymorphic
};

struct B: public A
{
    template <typename T2>
    class C
    {
      public:
          static void f (A& a)
          {
               dynamic_cast<B&>( a ).g();
          }
    };

    void g () {}
};



... and issues the following Error message:

test.cpp: In static member function 'static void B::Update<T2>::g(A&)':
test.cpp:21: error: request for member 'g' in 'dynamic_cast<B&>(a)', which is
of non-class type 'B&'


On the other hand, it works if either C is not a template or B is a template. 

this fails for 4.1.3, 4.2.2 and 4.3.0


-- 
           Summary: [4.1/4.2/4.3] class& is not known as as a class-type
                    anymore after dynamic_cast
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rbuergel at web dot de


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

Reply via email to