[LLVMbugs] [Bug 12204] New: static_cast to Base class overrides the Derived class field.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Mar 7 05:59:43 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=12204
Bug #: 12204
Summary: static_cast to Base class overrides the Derived class
field.
Product: clang
Version: 3.0
Platform: PC
OS/Version: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: nikhil.girdhar at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
struct Foo {
Foo() {};
int i;
short f;
};
struct Bar : public Foo {
Bar() {};
int b;
};
Bar b1, b2;
b2.i = 0;
b2.f = 1;
b2.b = 2;
b1.i = 3;
b1.f = 4;
b1.b = 5;
dynamic_cast<Foo&>(b1) = dynamic_cast<Foo&>(b2);
printf("b1.b = %d");
Output is 2 instead of 5.
static_cast restricted to the base class(Foo) should not have overridden the
Derived class field b. Please clarify.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list