This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/9221: Incorrect dynamic cast failure
- From: paterno at fnal dot gov
- To: gcc-gnats at gcc dot gnu dot org
- Cc: wb at fnal dot gov
- Date: 7 Jan 2003 21:36:22 -0000
- Subject: c++/9221: Incorrect dynamic cast failure
- Reply-to: paterno at fnal dot gov
>Number: 9221
>Category: c++
>Synopsis: Incorrect dynamic cast failure
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jan 07 13:46:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: paterno@fnal.gov
>Release: gcc (GCC) 3.2 20020927 (prerelease)
>Organization:
>Environment:
Cygwin 1.3.18-1, on Windows 2000.
>Description:
// The following code compiles with g++ -O0 dcast.cpp.
// The second assertion incorrectly fails.
#include <assert.h>
struct B1
{
virtual ~B1() {}
};
struct B2
{
virtual ~B2() {}
virtual B2* clone() const = 0;
};
struct D : public B1, public B2
{
D() : B1(), B2() { }
D* clone() const { return new D; }
};
int main()
{
D d;
B2* p1 = &d;
B2* pb = p1->clone();
assert ( pb != 0 );
D* pd = dynamic_cast<D*>(pb);
assert ( pd != 0 );
delete pb;
}
>How-To-Repeat:
Compile the source file with 'g++ -O0', or any other
optimization level.
>Fix:
No work-around known.
>Release-Note:
>Audit-Trail:
>Unformatted: