This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14688] New: Mis-matched calling convention on virtual functions accepted without error
- From: "dannysmith at users dot sourceforge dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Mar 2004 11:11:07 -0000
- Subject: [Bug c++/14688] New: Mis-matched calling convention on virtual functions accepted without error
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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