[Bug c++/15942] modifying data in a int * cast pointer to a pointer to a member has no effect when -O2 is used

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Fri Jun 11 17:14:00 GMT 2004


------- Additional Comments From bangerth at dealii dot org  2004-06-11 17:14 -------
This testcase is broken in so many ways that I have a hard time to 
motivate myself to write something about it. The first thing is your 
assumption that a pointer-to-member is stored in an object of size 8 
bytes. The second assumption is that it has a representation as if 
it were an integer. The third assumption is that you can write to 
a pointer-to-member variable through a pointer to integer. The fourth 
assumption is that the conversion to an integer yields something 
interesting at all. 
 
Assumptions 1, 2, and 4 are not portable and may or may not hold. 
Assumption 3 is plain wrong, and particularly prohibited by the aliasing 
rules of the standard. Given this, the fact that you get wrong results 
is not surprising. Using -fstrict-aliasing may be a way around your 
problem here, but we are certainly not interested in "fixing" the compiler 
to support code that is so far outside all standards. 
 
W. 

-- 


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



More information about the Gcc-bugs mailing list