This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/54388] std::array.at() const results in undefined behaviour
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 28 Aug 2012 08:21:21 +0000
- Subject: [Bug libstdc++/54388] std::array.at() const results in undefined behaviour
- Auto-submitted: auto-generated
- References: <bug-54388-4@http.gcc.gnu.org/bugzilla/>
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()