From: <no...@so...> - 2002-06-12 15:02:49
|
Bugs item #568054, was opened at 2002-06-13 00:02 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=102435&aid=568054&group_id=2435 Category: gcc Group: None Status: Open Resolution: None Priority: 5 Submitted By: Colin Peters (colinpeters) Assigned to: Danny Smith (dannysmith) Summary: GCC 3.1 dynamic_cast fails with DLLs Initial Comment: When attempting to use dynamic_cast in an executable to cast a base class pointer to an instance produced in a DLL to a derived class dynamic_cast fails, returning zero. e.g. class cFoo { ... }; class cBar : public cFoo { ... }; cFoo* pfoo = CreateBarInDLLAndCastToFoo(); cBar* pbar = dynamic_cast<cBar*>(pfoo); pbar ends up zero. The same code works as expected when compiled into a single executable or when I revert to gcc 2.95.3 and an older version of binutils. Attached is a simple test case demonstrating the problem. main.cpp is the executable, while foobar.cpp is built into a DLL. Doing a "make test" builds a static version static.exe and dynamic version dll.exe, then runs both. Sample output is included for make test with gcc 2.95.3 (old.out) and gcc 3.1 (new.out). If the test works properly, the printed output for the "Bar pointer" will be non-zero in both static and DLL cases. Note: The Makefile as it is builds with the -v flag. I also only used it under bash and with working versions of rm and echo available. ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=102435&aid=568054&group_id=2435 |