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

kfoltman@onet.pl kfoltman@onet.pl
Sun Mar 2 22:46:00 GMT 2003


>Number:         9908
>Category:       target
>Synopsis:       wrong code generated for virtual method call (gas bug?)
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 02 22:46:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Krzysztof Foltman
>Release:        gcc-3.2.2
>Organization:
>Environment:
Debian-x86, mingw - both give same effect
>Description:
Wrong call type is generated in -masm=intel mode. I'm not sure, but it looks like the .S file contains correct call (call dword ptr label+8), but it's assembled as near jump (E8 08 00 00 00) instead of indirect jump (FF 15 08 00 00 00). Checked by compiling both AT&T and Intel versions with -S, assembling with as and unassembling with ndisasmw.
>How-To-Repeat:
========== cut =======================

struct B {
  virtual int foo() { }
};

void check(void *pV)
{
  ((B *)pV)->foo();
}

int main(int argc, char *argv)
{
  B b;
  check((B *)&b);
}

========== cut =======================

# gcc-3.2 -O3 -masm=att -o inh inh.cpp -l stdc++ && ./inh
(this works)

# gcc-3.2 -O3 -masm=intel -o inh inh.cpp -l stdc++ && ./inh
(this segfaults)

100% repeatable both on mingw and debian gcc-3.2
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-prs mailing list