http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54388
--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-09-09 17:56:15 UTC --- (In reply to comment #10) > Can the compiler warn about the original (buggy) code? It already does: c.cc: In function ‘A& get(int)’: c.cc:3:43: error: invalid initialization of non-const reference of type ‘A&’ from an rvalue of type ‘A’ A& get(int i) { return i == 0 ? a : throw 1; } ^ But warnings are suppressed in system headers. --- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-09-09 17:56:56 UTC --- Author: redi Date: Sun Sep 9 17:56:51 2012 New Revision: 191114 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191114 Log: PR libstdc++/54388 * include/std/array (array::at() const): Ensure lvalue result. * testsuite/23_containers/array/element_access/54388.cc: New. * testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust dg-error line numbers. * testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc: Likewise. Added: trunk/libstdc++-v3/testsuite/23_containers/array/element_access/54388.cc - copied, changed from r191113, trunk/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/std/array trunk/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc trunk/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc