[Bug c++/15942] modifying data in a int * cast pointer to a pointer to a member has no effect when -O2 is used
indrek at mare dot ee
gcc-bugzilla@gcc.gnu.org
Fri Jun 11 16:59:00 GMT 2004
------- 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
More information about the Gcc-bugs
mailing list