http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54388
Bug #: 54388
Summary: std::array.at() const results in undefined behaviour
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: libstdc++
AssignedTo: [email protected]
ReportedBy: [email protected]
array line 166:
#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
{
return __n < _Nm ?
_M_instance[__n] : __throw_out_of_range(__N("array::at"));
}
#endif
Refer to
http://stackoverflow.com/questions/12136394/issue-with-bounds-checking-a-member-stdarray-inside-a-const-function
A conditional with a throw operand evaluates to a prvalue, which expires at the
end of the return statement.