[Bug libstdc++/54388] New: std::array.at() const results in undefined behaviour
lukeallardyce at yahoo dot co.uk
gcc-bugzilla@gcc.gnu.org
Tue Aug 28 02:26:00 GMT 2012
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: unassigned@gcc.gnu.org
ReportedBy: lukeallardyce@yahoo.co.uk
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.
More information about the Gcc-bugs
mailing list