www.digitalmars.com         C & C++   DMDScript  

c++.beta - DM 8.39 multiple inheritance bug ?

reply Riccardo Macri <Riccardo_member pathlink.com> writes:
The following runs to completion under 8.38 but crashes if compiled with 8.39.

Am I breaking a rule somewhere? The code this was extracted from has been fine
for years.

#include <stdio.h>

//
// The EXE produced by DM 8.39 crashes with this code!
//

// compile with "sc rickbug -mn"


class IFScrnRect
{
public:

IFScrnRect()           {}
virtual ~IFScrnRect()  {}
};


class SelectableObject
{
//
// Note: the bug disappears if the "static" RectUpdate() is renamed to
// something different.
//

public:

SelectableObject()            {}
virtual ~SelectableObject()   {}

static void RectUpdate()      {}

virtual void RectUpdate(int cmd);

};

void SelectableObject::RectUpdate(int cmd)
{
// this is what we expect main() To call

printf("RectUpdate:cmd is %d\n",cmd);
}

class BadText : public IFScrnRect,
public SelectableObject
{
public:

BadText()            {}
virtual ~BadText()   {}
};


main()
{
printf("1");
BadText * t = new BadText();
printf("2");

// DM 8.39 crashes here. v8.38 and SC 7.5 are OK
//
// In the full application it seems it was calling the wrong function.

t->RectUpdate(123);  
printf("3");
delete t;
printf("4");

return 0;
}
Feb 20 2004
parent "Matthew" <matthew.hat stlsoft.dot.org> writes:
Can you repost after converting tabs to spaces

"Riccardo Macri" <Riccardo_member pathlink.com> wrote in message
news:c158t9$2e3v$1 digitaldaemon.com...
 The following runs to completion under 8.38 but crashes if compiled with

 Am I breaking a rule somewhere? The code this was extracted from has been

 for years.

 #include <stdio.h>

 //
 // The EXE produced by DM 8.39 crashes with this code!
 //

 // compile with "sc rickbug -mn"


 class IFScrnRect
 {
 public:

 IFScrnRect()           {}
 virtual ~IFScrnRect()  {}
 };


 class SelectableObject
 {
 //
 // Note: the bug disappears if the "static" RectUpdate() is renamed to
 // something different.
 //

 public:

 SelectableObject()            {}
 virtual ~SelectableObject()   {}

 static void RectUpdate()      {}

 virtual void RectUpdate(int cmd);

 };

 void SelectableObject::RectUpdate(int cmd)
 {
 // this is what we expect main() To call

 printf("RectUpdate:cmd is %d\n",cmd);
 }

 class BadText : public IFScrnRect,
 public SelectableObject
 {
 public:

 BadText()            {}
 virtual ~BadText()   {}
 };


 main()
 {
 printf("1");
 BadText * t = new BadText();
 printf("2");

 // DM 8.39 crashes here. v8.38 and SC 7.5 are OK
 //
 // In the full application it seems it was calling the wrong function.

 t->RectUpdate(123);
 printf("3");
 delete t;
 printf("4");

 return 0;
 }

Feb 20 2004