This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: target/9908: wrong code generated for virtual method call (NOT a gas bug)
- From: "Krzysztof Foltman" <kfoltman at onet dot pl>
- To: <gcc-bugs at gcc dot gnu dot org>
- Date: Mon, 3 Mar 2003 00:27:14 +0100
- Subject: Re: target/9908: wrong code generated for virtual method call (NOT a gas bug)
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=g
cc&pr=9908
Clarification/correction:
Wrong call type is generated in -masm=intel mode. The virtual method
call is emitted to .S file as:
call DWORD PTR __ZTV1B+8
which is interpreted as a NEAR call to label __ZTV1B+8 (jump to the
middle of the vtable, obviously wrong).
The version that would work is:
call DWORD PTR [__ZTV1B+8]
As an alternative, GNU Assembler could treat call dword ptr label as
call dword ptr [label] (which is, I think, a correct interpretation). Or
it could emit a warning (the interpretation of 'dword ptr' as a near
address to call doesn't seem correct to me).
You can confirm the difference using the following snippet:
gcc -O3 -masm=att -c inh.cpp && objdump -S inh.o >file1
gcc -O3 -masm=intel -c inh.cpp && objdump -S inh.o >file2
diff file1 file2
inh.cpp is the above code snippet.
Krzysztof