This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/22132] Wrong code: upcasting a const class pointer to struct the class derives from
- From: "scott dot tupaj at line6 dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Jun 2005 17:01:40 -0000
- Subject: [Bug c++/22132] Wrong code: upcasting a const class pointer to struct the class derives from
- References: <20050621013546.22132.scott.tupaj@line6.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From scott dot tupaj at line6 dot com 2005-06-21 17:01 -------
Yes, agreeably this is 'bad' c++ practice in my example. However, if wrong
code is produced, I think it would be prudent for at least a compiler warning
or error be produced if the reason for wrong code is because invalid or
questionable c++ syntax is being used.
Every other compiler I've used, including gcc 3.x.x doesn't not corrupt access
to the members in this scenario like gcc 4.0.0 does. Other compilers either
error because of the const violation, or accepts it and produces the proper
results when accessing the pointer.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22132