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] [4.7/4.8 Regression] std::array.at() const results in undefined behaviour


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)


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