This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++ permissiveness?
- From: Stephane Del Pino <delpino at ann dot jussieu dot fr>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 24 Jan 2003 14:09:50 +0100
- Subject: g++ permissiveness?
- Organization: Laboratoire Jacques-Louis Lions
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi there.
I have noticed some strange behaviour of the compiler on the following example
but I am not sure if the compiler acts well or just misses the syntax
error... Could some one enlighten my view?
- --8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<---
struct A
{
};
int main()
{
const A& a = a;
const A& b = dynamic_cast<const A&>(b);
A& c = c;
A& d = dynamic_cast<A&>(d);
const double& e = e;
const double& f = dynamic_cast<const double&>(f);
double& g = g;
double& h = dynamic_cast<double&>(h);
const double& i = static_cast<const double&>(i);
return 0;
}
- --8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<---
The above code obiousely does not compile but if the lines 15 and 18 are
commented, it does! This is what I do not understand...
With g++-3.2 I get the following message (the same is obtained with 2.95 and
3.0)...
question.cpp: In function `int main()':
question.cpp:15: cannot dynamic_cast `f' (of type `const double') to type `
const double&' (target is not pointer or reference to class)
question.cpp:18: cannot dynamic_cast `h' (of type `double') to type `double&'
(
target is not pointer or reference to class)
Best regards,
Stephane.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+MTsebZyhKhZwdc0RAhj/AKCj+LLfdTTTsbxnG4lkuULVrRqungCePJ4E
K4hrZtOmqZpHIHM5DSEW4ho=
=asBd
-----END PGP SIGNATURE-----