http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50025
Summary: C++0x initialization syntax doesn't work for class members of reference type Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: akrze...@gmail.com The following code does not compile although I expect it to: /// BEGIN CODE /// #include <utility> struct S {}; struct C { S & mc2; S && mc3; C( S& b, S && c ) : mc2{b}, mc3{std::move(c)} {} }; int main() { return 0; } /// END CODE /// I compile it with command: g++ test.cpp -std=c++0x -o test.exe The output is: test.cpp: In constructor ‘C::C(S&, S&&)’: test.cpp:9:48: error: invalid initialization of non-const reference of type ‘S&’ from an rvalue of type ‘<brace-enclosed initializer list>’ test.cpp:9:48: error: invalid initialization of reference of type ‘S&&’ from expression of type ‘<brace-enclosed initializer list>’ Compiler version (g++ -v): Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-redhat-linux/4.6.0/lto-wrapper Target: i686-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch=i686 --build=i686-redhat-linux Thread model: posix gcc version 4.6.0 20110428 (Red Hat 4.6.0-6) (GCC)