bug report : avoid pointers to member...

francois.gorisse@fra.modicon.com francois.gorisse@fra.modicon.com
Tue Oct 26 01:42:00 GMT 1999


I was working with Tornado 2 developpement system when this message appear :

cc386 -O1 -g -mpentium -ansi -nostdinc -DRW_MULTI_THREAD -D_REENTRANT -fvolatile
 -nostdlib
 -fno-builtin -fno-defer-pop -I. -ID:\BusX\h -IC:\Tornado2\target\h
-DCPU=PENTIUM -c D:\Bu
sX\bug.cpp
D:\BusX\bug.cpp: In method `void bug::launch()':
D:\BusX\bug.cpp:29: Internal compiler error.
D:\BusX\bug.cpp:29: Please submit a full bug report to `egcs-bugs@cygnus.com'.
make: *** [bug.o] Error 0x1

So, as you want ! Here is the source code  (one file is enought) :

///////////////////////////////////////BEGIN of Bug.cpp
class bug;

// External function equivalent to main()
void toto(void);

// It is the class is n't it ?
class bug
{
public:
// Members
  void launch(void); // this function call a pointer to a member
  void m_func(void) { value++; } ; // here just to be the calledmember

// Data
  void (bug:: * function)(void); // Declaration of a pointer to a member
  int value; // no interest
};

void toto(void)
{
  // Declare the class
  bug pbug;

  // and call the function
  pbug.launch();
}

void bug::launch(void)
{
  function = &m_func; // OK

  this->function();   // Compiler internal error !!!
}
///////////////////////////////////////END of Bug.cpp

Note : Stroustrup in the C++ 3rd edition §15.5 p418 seems to autherize this
code.

Note 2 : I 'm particulary found of champagne !

          Francois GORISSE.


More information about the Gcc-bugs mailing list