[Bug c++/14688] New: Mis-matched calling convention on virtual functions accepted without error
dannysmith at users dot sourceforge dot net
gcc-bugzilla@gcc.gnu.org
Tue Mar 23 11:11:00 GMT 2004
Hello,
The following i386 bug was reported to mingw list by Justin Forest.
No error nor even a warning message is emitted when a virtual function in a
derived class uses a different calling convention than the function
in the base class. In the testcase that follows, this leads to the passing
of undefined parameters to the inherited method.
// virtual_mismatch.cc
#include <stdio.h>
class one {
public:
virtual void test(void* value);
};
class two : public one {
public:
void __attribute__((regparm(2))) test(void* value);
};
void one::test(void* value)
{
printf("one::test(%p, %p)\n", this, value);
}
void two::test(void* value)
{
printf("two::test(%p, %p)\n", this, value);
}
int main(int argc, const char **argv)
{
two t;
one *o = &t;
t.test(o); // a direct call,
// parameters passed through registers, ok
o->test(o); // called through one::vtable,
// parameters put to stack, read from registers
return 0;
}
This compiles without warning;
> g++ -Wall -ovirtual_mismatch virtual_mismatch,cc
and produces:
> virtual_mismatch
> two::test(0022FF68, 0022FF68)
> two::test(00401282, 004041CC)
The problem was reported against 3.3.3 but occurs also on trunk and 3.4.
Danny
--
Summary: Mis-matched calling convention on virtual functions
accepted without error
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dannysmith at users dot sourceforge dot net
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-pc-mingw32
GCC host triplet: i386-pc-mingw32
GCC target triplet: i386-pc-mingw32
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14688
More information about the Gcc-bugs
mailing list