This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15942] modifying data in a int * cast pointer to a pointer to a member has no effect when -O2 is used
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Jun 2004 17:14:29 -0000
- Subject: [Bug c++/15942] modifying data in a int * cast pointer to a pointer to a member has no effect when -O2 is used
- References: <20040611161330.15942.indrek@mare.ee>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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