This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/477: problem casting member function pointer



>Number:         477
>Category:       c++
>Synopsis:       problem casting member function pointer
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 16 19:46:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     sondheim@knxmail.com <Loren Osborn>
>Release:        gcc 2.95.2
>Organization:
>Environment:
Linux/Mandrake 7.0
>Description:
We are having trouble with gcc with a feature that we
aren't sure if it is ANSI C++ compliant.  As such, we
are unsure if this is a bug in our code, or yours...

We *DO* have a workaround (illustrated below), but
converting our code-base to use the work around would
be a significant task.

So my questions are as follows:

1) Are both of the following ANSI C++ compliant?

2) Should gcc recognize both of these cases as equivilant?

3) Do versions newer than 2.95.2 support this?


All help is very greatly appreciated.

Thank you, 

	-Loren
>How-To-Repeat:
class Foo {
};

class Bar: public Foo {
  public:
	int my_func(int);
	int func(int);
};

int Bar::func(int num) {
	return num;
}

typedef int (Foo::*func_ptr)(int);

int use_func( Foo *my_foo, func_ptr func_arg, int val ) {
	return (my_foo->*func_arg)(val);
}

int Bar::my_func ( int my_val ) {
#ifdef WORK
	return use_func( this, (func_ptr) &Bar::func, my_val );
#else
	return use_func( this, (func_ptr) func, my_val );
#endif

}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]