Article View: gnu.g++.bug
Article #1857BUG in G++ 1.34.1 code generation
From: Ron Guilmette
Date: Wed, 12 Apr 1989 23:43
Date: Wed, 12 Apr 1989 23:43
118 lines
2897 bytes
2897 bytes
It seems that G++ 1.34.1 may not always correctly disambiguate
method references when the & (address-of) operator is used.
It looks like this can result in incorrect code generation
as demonstrated below.
What follows is a short example source file followed by the
code generated for it (on a Sun3) by G++ 1.34.1. It appears
that the code generated for the final assignment to "vp"
within the function called "test" is incorrect.
--------------------------------------------------------------------
// Check that it is legal to take the address of an overloaded
// operator as long as the context of the & operator requires
// that a specific (unambigous) type of pointer-to-function
// with arguments be yielded by the &.
// #include "Testinc.h"
overload function;
void function (char c)
{
c = c;
}
void function (float f)
{
f = f;
}
class base {
public:
void method (char);
void method (float);
};
void* vp;
typedef void (*ptr_to_func_of_char)(char);
typedef void (*ptr_to_func_of_float)(float);
typedef void (base::*ptr_to_method_of_char)(char);
typedef void (base::*ptr_to_method_of_float)(float);
int test ()
{
vp = (ptr_to_func_of_char) &function;
vp = (ptr_to_func_of_float) &function;
vp = (ptr_to_method_of_char) &base::method;
vp = (ptr_to_method_of_float) &base::method; // bad code?
return 0;
}
void base::method (char c)
{
c = c;
}
void base::method (float f)
{
f = f;
}
----------------------------------------------------------------------
#NO_APP
gcc_compiled.:
.text
.even
.globl _function_QI
_function_QI:
link a6,#0
moveb a6@(11),a6@(11)
L1:
unlk a6
rts
.even
.globl _function_SF
_function_SF:
link a6,#0
L2:
unlk a6
rts
.even
.globl _test
_test:
link a6,#0
movel #_function_QI,_vp
movel #_function_SF,_vp
movel #_method_PSbase_QI,_vp
movel #_method_PSbase_QI,_vp ; should be #_method_PSbase_SF
clrl d1
movel d1,d0
jra L3
L3:
unlk a6
rts
.even
.globl _method_PSbase_QI
_method_PSbase_QI:
link a6,#0
moveb a6@(15),a6@(15)
L4:
unlk a6
rts
.even
.globl _method_PSbase_SF
_method_PSbase_SF:
link a6,#0
L5:
unlk a6
rts
.comm _vp,4
----------------------------------------------------------------------------
// Ron Guilmette - MCC - Experimental Systems Kit Project
// 3500 West Balcones Center Drive, Austin, TX 78759 - (512)338-3740
// ARPA: rfg@mcc.com
// UUCP: {rutgers,uunet,gatech,ames,pyramid}!cs.utexas.edu!pp!rfg
Technical Details
Message-ID:
<8904122343.AA22884@riunite.aca.mcc.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!MCC.COM!rfgShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!MCC.COM!rfg From: rfg@MCC.COM (Ron Guilmette) Newsgroups: gnu.g++.bug Subject: BUG in G++ 1.34.1 code generation Message-ID: <8904122343.AA22884@riunite.aca.mcc.com> Date: 12 Apr 89 23:43:50 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 118