public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14688] New: Mis-matched calling convention on virtual functions accepted without error
@ 2004-03-23 11:11 dannysmith at users dot sourceforge dot net
  2004-03-23 14:46 ` [Bug c++/14688] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2004-03-23 11:11 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/14688] Mis-matched calling convention on virtual functions accepted without error
  2004-03-23 11:11 [Bug c++/14688] New: Mis-matched calling convention on virtual functions accepted without error dannysmith at users dot sourceforge dot net
@ 2004-03-23 14:46 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-23 14:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-23 14:46 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |accepts-invalid
      Known to fail|                            |2.95.3 3.2.3 3.3.4 3.4.0
                   |                            |3.5.0
   Last reconfirmed|0000-00-00 00:00:00         |2004-03-23 14:46:53
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14688


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-03-23 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-23 11:11 [Bug c++/14688] New: Mis-matched calling convention on virtual functions accepted without error dannysmith at users dot sourceforge dot net
2004-03-23 14:46 ` [Bug c++/14688] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).