target/9908: wrong code generated for virtual method call (NOT a gas bug)

Krzysztof Foltman kfoltman@onet.pl
Sun Mar 2 23:06:00 GMT 2003


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



More information about the Gcc-bugs mailing list