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]

Misleading typo in C++ error


Hi,

Compiling the following snippet (2.95.2)

class A {};
class B : public A {};

void f(const A& a)
{
  dynamic_cast<B*>(&a);

  const A a2;
  dynamic_cast<B*>(&a2);
}

leads to

error.cpp: In function `void f(const A &)':
error.cpp:6: cannot dynamic_cast `+a' (of type `const class A *') to type
`class B*'
error.cpp:8: uninitialized const `a2'
error.cpp:9: cannot dynamic_cast `&a2' (of type `const class A *') to type
`class B*'

I suppose the error message on line 6 should print '&a' instead of `+a',
just as it does on line 9?

Peter

-------------------------------------
Peter Bienstman
Department of Information Technology
INTEC/IMEC - University of Gent
St.-Pietersnieuwstraat 41
B-9000 Gent - Belgium
E-mail: Peter.Bienstman@rug.ac.be
Tel: +32 9 264 3445
Fax: +32 9 264 3593
-------------------------------------


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