This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/54388] [4.7/4.8 Regression] std::array.at() const results in undefined behaviour
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 28 Aug 2012 14:07:11 +0000
- Subject: [Bug libstdc++/54388] [4.7/4.8 Regression] 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 #6 from Daniel KrÃgler <daniel.kruegler at googlemail dot com> 2012-08-28 14:07:11 UTC ---
(In reply to comment #5)
> The paper does have implementation experience, and experience shows we got it
> wrong ;)
We implemented it wrong is a different message than "we couldn't implement it"
> We could do:
>
> return __n < _Nm ? _M_instance[__n]
> : (std::__throw out_of_range(__N("array::at")), _M_instance[0]);
>
> and still get rid of the code that's conditionally compiled on __EXCEPTIONS.
>
> N.B. the second branch uses _M_instance[0] to avoid possible warnings about
> out-of-bounds accesses.
Yes, this should also work (I noticed that gcc gets an ICE in any of my
suggested forms. I will investigate this separately)