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; 9+ 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] 9+ 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; 9+ 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] 9+ messages in thread

* [Bug c++/14688] Mis-matched calling convention on virtual functions accepted without error
       [not found] <bug-14688-4066@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2007-09-25  0:30 ` dannysmith at gcc dot gnu dot org
@ 2007-09-25  0:31 ` dannysmith at users dot sourceforge dot net
  6 siblings, 0 replies; 9+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2007-09-25  0:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from dannysmith at users dot sourceforge dot net  2007-09-25 00:31 -------
Fixed on trunk 


-- 

dannysmith at users dot sourceforge dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

* [Bug c++/14688] Mis-matched calling convention on virtual functions accepted without error
       [not found] <bug-14688-4066@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2007-09-19  2:24 ` patchapp at dberlin dot org
@ 2007-09-25  0:30 ` dannysmith at gcc dot gnu dot org
  2007-09-25  0:31 ` dannysmith at users dot sourceforge dot net
  6 siblings, 0 replies; 9+ messages in thread
From: dannysmith at gcc dot gnu dot org @ 2007-09-25  0:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from dannysmith at gcc dot gnu dot org  2007-09-25 00:29 -------
Subject: Bug 14688

Author: dannysmith
Date: Tue Sep 25 00:29:42 2007
New Revision: 128740

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128740
Log:
        PR c++/14688
        * config/i386/i386.c (ix86_comp_type_attributes): Check
        METHOD_TYPE too.

cp
        * search.c (check_final_overrider): Fail if
        targetm.comp_type_attributes returns 0.

testsuite
        * g++.dg/inherit/override_attribs.C: New file.

Added:
    trunk/gcc/testsuite/g++.dg/inherit/override-attribs.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/search.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/14688] Mis-matched calling convention on virtual functions accepted without error
       [not found] <bug-14688-4066@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2007-09-19  0:59 ` dannysmith at users dot sourceforge dot net
@ 2007-09-19  2:24 ` patchapp at dberlin dot org
  2007-09-25  0:30 ` dannysmith at gcc dot gnu dot org
  2007-09-25  0:31 ` dannysmith at users dot sourceforge dot net
  6 siblings, 0 replies; 9+ messages in thread
From: patchapp at dberlin dot org @ 2007-09-19  2:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from patchapp at dberlin dot org  2007-09-19 02:24 -------
Subject: Bug number PR 14688

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01498.html


-- 


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


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

* [Bug c++/14688] Mis-matched calling convention on virtual functions accepted without error
       [not found] <bug-14688-4066@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2007-05-14  9:58 ` justin dot forest at gmail dot com
@ 2007-09-19  0:59 ` dannysmith at users dot sourceforge dot net
  2007-09-19  2:24 ` patchapp at dberlin dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2007-09-19  0:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from dannysmith at users dot sourceforge dot net  2007-09-19 00:58 -------
Patch at:
http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01498.html

Danny


-- 


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


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

* [Bug c++/14688] Mis-matched calling convention on virtual functions accepted without error
       [not found] <bug-14688-4066@http.gcc.gnu.org/bugzilla/>
  2006-11-20 12:22 ` massimiliano dot ghilardi at gmail dot com
  2006-11-20 14:04 ` massimiliano dot ghilardi at gmail dot com
@ 2007-05-14  9:58 ` justin dot forest at gmail dot com
  2007-09-19  0:59 ` dannysmith at users dot sourceforge dot net
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: justin dot forest at gmail dot com @ 2007-05-14  9:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from justin dot forest at gmail dot com  2007-05-14 10:57 -------
$ g++ --version
i686-apple-darwin8-g++- 4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build
5250)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

$ g++ -o test test.cc && ./test
two::test(0xbffff7d8, 0xbffff7d8)
two::test(0xbffff7d8, 0x1b94)

Still looks like a valid issue.


-- 


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


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

* [Bug c++/14688] Mis-matched calling convention on virtual functions accepted without error
       [not found] <bug-14688-4066@http.gcc.gnu.org/bugzilla/>
  2006-11-20 12:22 ` massimiliano dot ghilardi at gmail dot com
@ 2006-11-20 14:04 ` massimiliano dot ghilardi at gmail dot com
  2007-05-14  9:58 ` justin dot forest at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: massimiliano dot ghilardi at gmail dot com @ 2006-11-20 14:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from massimiliano dot ghilardi at gmail dot com  2006-11-20 14:04 -------
Duplicated Bug 29909 also points out the not-so-obvious case where the
overridden virtual method is actually the automatically-compiler-generated
derived class destructor:

// compile with g++ -Wall -O

class one {
public:
        virtual __attribute((regparm(3))) ~one();
};

class two : public one {
};

int main() { 
        one * o = new two();                                                   
                                                                        delete
o;                                                                             
                                                         return 0;             
                                                                               
                                   }


-- 


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


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

* [Bug c++/14688] Mis-matched calling convention on virtual functions accepted without error
       [not found] <bug-14688-4066@http.gcc.gnu.org/bugzilla/>
@ 2006-11-20 12:22 ` massimiliano dot ghilardi at gmail dot com
  2006-11-20 14:04 ` massimiliano dot ghilardi at gmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: massimiliano dot ghilardi at gmail dot com @ 2006-11-20 12:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from massimiliano dot ghilardi at gmail dot com  2006-11-20 12:21 -------
*** Bug 29909 has been marked as a duplicate of this bug. ***


-- 

massimiliano dot ghilardi at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |massimiliano dot ghilardi at
                   |                            |gmail dot com


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


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

end of thread, other threads:[~2007-09-25  0:31 UTC | newest]

Thread overview: 9+ 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
     [not found] <bug-14688-4066@http.gcc.gnu.org/bugzilla/>
2006-11-20 12:22 ` massimiliano dot ghilardi at gmail dot com
2006-11-20 14:04 ` massimiliano dot ghilardi at gmail dot com
2007-05-14  9:58 ` justin dot forest at gmail dot com
2007-09-19  0:59 ` dannysmith at users dot sourceforge dot net
2007-09-19  2:24 ` patchapp at dberlin dot org
2007-09-25  0:30 ` dannysmith at gcc dot gnu dot org
2007-09-25  0:31 ` dannysmith at users dot sourceforge dot net

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).