This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/54388] std::array.at() const results in undefined behaviour


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54388

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-08-28 08:21:21 UTC ---
The fix is to remove the constexpr from array::at, which isn't required by the
standard anyway:

diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array
index 58263ce..88595c0 100644
--- a/libstdc++-v3/include/std/array
+++ b/libstdc++-v3/include/std/array
@@ -164,14 +164,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        return _M_instance[__n];
       }

-#ifdef __EXCEPTIONS
-      constexpr const_reference
-      at(size_type __n) const
-      {
-       return __n < _Nm ? 
-              _M_instance[__n] : throw out_of_range(__N("array::at"));
-      }
-#else
       const_reference
       at(size_type __n) const
       {
@@ -179,7 +171,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          std::__throw_out_of_range(__N("array::at"));
        return _M_instance[__n];
       }
-#endif

       reference 
       front()


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]