https://bugs.llvm.org/show_bug.cgi?id=33487
Bug ID: 33487
Summary: dynamic_cast to ambiguous derived class produces the
wrong answer
Product: libc++abi
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: unassignedb...@nondot.org
Reporter: arthur.j.odw...@gmail.com
CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com
This is similar to bug 33439, but in that case we're casting between unrelated
types where the most derived type contains multiple (ambiguous) subobjects of
the destination type. In *this* case we're casting between related types — from
a base subobject to a derived type — where the source object is a subobject of
more than one object of the destination type. In both cases the symptom is
similar: dynamic_cast returns a pointer to the first such ambiguous subobject,
when it should be returning NULL.
#include <stdio.h>
struct Class1 { virtual ~Class1() {} };
struct Shared : public virtual Class1 {};
struct Class6 : public virtual Shared {};
struct Left : public Class6 {};
struct Right : public Class6 {};
struct Main : public Left, public Right {};
int main()
{
Main m;
Class1 *c1 = &m;
Class6 *c6 = dynamic_cast<Class6*>(c1);
printf("%p, should be nullptr\n", c6);
}
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs