[Bug c++/22132] Wrong code: upcasting a const class pointer to struct the class derives from

scott dot tupaj at line6 dot com gcc-bugzilla@gcc.gnu.org
Tue Jun 21 17:01:00 GMT 2005


------- 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



More information about the Gcc-bugs mailing list