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: "indrek at mare dot ee" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Jun 2004 16:59:38 -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 indrek at mare dot ee 2004-06-11 16:59 -------
I know it's a hack. But it's a hack that has consistently served me on varous
platforms (and compilers) considering c++ limitations at handling array of
member pointers. I got over it myself by using memcpy instead. Still c and c++
languages allow casts for some reason. Or if this is incorrect - then why does
gcc allow to compile it anyway.
Also this behaviour is not consistent. For example add printf("%x\n", &n[j]);
before the increment line, like this:
for ( int j = 0; j < 8; j++ ) {
n[j] = (int a::*)&a::x;
printf("%x\n", &n[j]);
*(int *)&n[j] += j*8;
}
And it'll give you different (correct) output - the memory gets changed. Maybe
it's not a big deal for you but this might hint of other more sinister bug
inside gcc. I wont bother you any more.
Also this bug seems not to manifest on i386 platform or another arm compiler I used.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15942