[llvm-bugs] [Bug 33487] New: dynamic_cast to ambiguous derived class produces the wrong answer
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jun 16 12:39:53 PDT 2017
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: unassignedbugs at nondot.org
Reporter: arthur.j.odwyer at gmail.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170616/7d2d979f/attachment.html>
More information about the llvm-bugs
mailing list