This is the mail archive of the gcc-bugs@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]

either g++ fails to properly typecheck pointer-to-member assignment, or I am on some bad crack



% g++ -v
Reading specs from /home/kosak/bloco/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.91.04/specs
gcc version egcs-2.91.04 980115 (gcc-2.8.0 release)

% cat member-function-bug.cc 
#include <iostream.h>

class cow {
public:
  void moo (char *x);
  void func();
};

void cow::moo(char *x)
{
  cout <<"Hello, welcome to coo::moo(char*)\n";
  cout <<"x is " <<x <<"\n";  // segfault here because I got the wrong thing
}


void cow::func()
{
  void (cow::*fp)(int) = &moo; // I deserve a type mismatch
  (this->*fp)(77);
}


int main()
{
  cow x;
  x.func();
}


% g++ member-function-bug.cc 


% ./a.out
Hello, welcome to coo::moo(char*)
Segmentation fault


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