This is the mail archive of the mailing list for the Cygwin project. See the Cygwin home page for more information.
[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index] [Subject Index] [Author Index] [Thread Index]

This C++ code fails

This small test program demonstrates a problem I am having with virtual base
classes and a pointer to member.

When I try to call a function in a class that has virtual base classes
through a pointer to member the program crashes.

I have compiled and run this same test successfully under Borland C++ 5.02

I am using cygwin B20.1 with EGCS 1.1.1 installed. You can compile the test
using the command "gcc Try.cpp -o Try.exe". When the program is run I get
the following output:

bash-2.02$ gcc try.cpp -o try.exe
bash-2.02$ ./try
Calling Test1::Click directly.
void Test1::Click(void)
Calling Test1::Click through pointer to member.
void Test1::Click(void)
Calling Test2::Click directly.
void Test2::Click(void)
Calling Test2::Click through pointer to member.
[main] D:\race\test\try.exe 1016 (0) handle_exceptions: Exception:
[main] try 1016 (0) handle_exceptions: Dumping stack trace to try.exe.core

The Test2 class is using virtual base classes, unlike the Test1 class. This
difference causes an exception to be thrown when the pointer to member is

Any help would be much appreciated.


Want to unsubscribe from this list?
Send a message to