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: unassig...@gcc.gnu.org
        ReportedBy: ro...@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

Reply via email to