Article View: gnu.g++.bug
Article #261pointer to member bug
From: Jakov Seizovic
Date: Tue, 14 Apr 1992 18:37
Date: Tue, 14 Apr 1992 18:37
79 lines
2468 bytes
2468 bytes
------------------------------------------------------------------------------
machine used: SPARCstation 2
------------------------------------------------------------------------------
------------------------------------------------------------------------------
g++ version used:
------------------------------------------------------------------------------
% g++ -v -S bug.c
Reading specs from /usr/local/lib/gcc-lib/sun4/2.1/specs
gcc version 2.1
/usr/local/lib/gcc-lib/sun4/2.1/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix bug.c /usr/tmp/cca15524.i
GNU CPP version 2.1 (sparc)
/usr/local/lib/gcc-lib/sun4/2.1/cc1plus /usr/tmp/cca15524.i -quiet -dumpbase bug.cc -version -o bug.s
GNU C++ version 2.1 (sparc) compiled by GNU C version 2.1.
%
------------------------------------------------------------------------------
source code:
------------------------------------------------------------------------------
class C
{
public:
int i0;
int i1;
};
typedef int C::* PMC;
int j;
void
f ()
{
PMC pmc = &C::i1;
C c;
C* cp = &c;
j = cp->*pmc; // problem occurs here
}
------------------------------------------------------------------------------
produced assembly code:
------------------------------------------------------------------------------
gcc2_compiled.:
.text
.align 4
.global _f__Fv
.proc 1
_f__Fv:
!#PROLOGUE# 0
save %sp,-136,%sp
!#PROLOGUE# 1
mov 4,%o0
st %o0,[%fp-20]
add %fp,-32,%o0
st %o0,[%fp-36]
sethi %hi(_j),%o0
ld [%fp-20],%o1
ld [%fp-36],%o2
ld [%o1],%o3 // memory(0x0004) is accessed here
add %o2,%o3,%o1
ld [%o1],%o2
st %o2,[%o0+%lo(_j)]
b,a L2
b,a L1
L2:
L1:
ret
restore
.global _j
.common _j,8,"bss"
Technical Details
Message-ID:
<9204141837.AA25099@vlsi.cs.caltech.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!vlsi.cs.caltech.edu!jakovShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!vlsi.cs.caltech.edu!jakov From: jakov@vlsi.cs.caltech.edu (Jakov Seizovic) Subject: pointer to member bug Message-ID: <9204141837.AA25099@vlsi.cs.caltech.edu> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Tue, 14 Apr 1992 18:37:25 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 82