This code fails to compile on current mainline: ------------- class A { A(const A&); }; const A GetA(); void caller() { const A& a = GetA(); } -----------------------------
with this error: access-const-ref.cpp: In function `void caller()': access-const-ref.cpp:3: error: 'A::A(const A&)' is private access-const-ref.cpp:10: error: within this context It compiles fine on gcc 3.3.3. compiler version: $ gcc -v Reading specs from /usr/gcc4/lib/gcc/i686-pc-linux-gnu/4.0.0/specs Configured with: ../gcc/configure --prefix=/usr/gcc4 --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --disable-libgcj --enable-languages=c,c++ Thread model: posix gcc version 4.0.0 20041011 (experimental) -- Summary: cannot assign result to const reference if copy ctor is not accessible Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bryner at brianryner dot com CC: gcc-bugs at gcc dot gnu dot org GCC host triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17938