http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53288
Bug #: 53288 Summary: [C++11] Reference fails to bind directly to prvalue member access expression Classification: Unclassified Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: hst...@ca.ibm.com Host: powerpc64-unknown-linux-gnu Target: powerpc64-unknown-linux-gnu In the reference initialization, const B &b = A(1).b; the initializer expression is a class prvalue. The requirement to bind an lvalue reference to a non-volatile const type directly to a reference-compatible class prvalue dates back to DR 391 which PR 25950 intended to implement. The error messages complaining about the private and deleted move constructor indicate that direct binding was not done. ### Self-contained source (tempbind_expr_ref.cpp):> cat tempbind_expr_ref.cpp extern "C" int printf(const char *, ...); struct B { B(int data) : _data(data) { printf("ctor B(int) body: (this=%p,_data=%d)\n", (void *)this, _data); } ~B() { printf("dtor for B: (this=%p,_data=%d)\n", (void *)this, _data); } int _data; private: B() = delete; B(const B &) = delete; B(B &&) = delete; }; struct A { B b; A(int data) : b(data) { printf("ctor A(int) body: (this=%p,_data=%d)\n", (void *)this, b._data); } ~A() { printf("dtor for A: (this=%p,_data=%d)\n", (void *)this, b._data); } private: A() = delete; A(const A &) = delete; A(A &&) = delete; }; const B &b = A(1).b; int main() { printf("main() user body begins\n"); printf("main() user body ends\n"); } ### Compiler invocation: g++-4.6.0 tempbind_expr_ref.cpp -std=c++0x ### Compiler output: tempbind_expr_ref.cpp:16:4: error: 'B::B(B&&)' is private tempbind_expr_ref.cpp:34:19: error: within this context tempbind_expr_ref.cpp:34:19: error: use of deleted function 'B::B(B&&)' tempbind_expr_ref.cpp:16:4: error: declared here ### g++ -v output:> g++-4.6.0 -v Using built-in specs. COLLECT_GCC=g++-4.6.0 COLLECT_LTO_WRAPPER=/data/gcc/libexec/gcc/powerpc64-unknown-linux-gnu/4.6.0/lto-wrapper Target: powerpc64-unknown-linux-gnu Configured with: ./configure --prefix=/data/gcc --program-suffix=-4.6.0 --disable-libssp --disable-libgcj --enable-version-specific-runtime-libs --with-cpu=default32 --enable-secureplt --with-long-double-128 --enable-shared --enable-__cxa_atexit --enable-threads=posix --enable-languages=c,c++,fortran --with-gmp=/usr/local Thread model: posix gcc version 4.6.0 (GCC)