This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
- From: "roman at binarylife dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 04 Dec 2011 07:31:24 +0000
- Subject: [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406
Bug #: 51406
Summary: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of
static_cast to rvalue reference to base class.
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: roman@binarylife.net
$ cat test.cpp
#include <stdlib.h>
#include <iostream>
struct A { int a; A() : a(1) {} };
struct B { int b; B() : b(2) {} };
struct X : A, B {};
int main() {
X x;
int a=static_cast<A&&>(x).a;
int b=static_cast<B&&>(x).b;
std::cout<<"a="<<a<<", b="<<b<<std::endl;
if (a!=1 || b!=2) abort();
}
$ g++ -std=c++0x test.cpp && ./a.out
a=1, b=1
Aborted