public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/53080] New: std::array - std::get() and std::tuple_element is nothing bounds check
@ 2012-04-23 2:15 faithandbrave at gmail dot com
2012-04-23 8:36 ` [Bug libstdc++/53080] tuple interface to std::array doesn't check bounds redi at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: faithandbrave at gmail dot com @ 2012-04-23 2:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53080
Bug #: 53080
Summary: std::array - std::get() and std::tuple_element is
nothing bounds check
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: faithandbrave@gmail.com
"23.3.2.9 Tuple interface to class template array" in N3337(C++ Specification
Draft)
tuple_element<I, array<T, N> >::type
Requires: I < N. The program is ill-formed if I is out of bounds.
template <size_t I, class T, size_t N> T& get(array<T, N>& a) noexcept;
Requires: I < N. The program is ill-formed if I is out of bounds.
GCC 4.7.0 libstdc++ <array> header is no check bounds.
I think need static_assert to tuple_element and get().
Issue code is follow:
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
struct tuple_element<_Int, array<_Tp, _Nm> >
{ typedef _Tp type; };
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
constexpr _Tp&
get(array<_Tp, _Nm>& __arr) noexcept
{ return __arr._M_instance[_Int]; }
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
constexpr _Tp&&
get(array<_Tp, _Nm>&& __arr) noexcept
{ return std::move(get<_Int>(__arr)); }
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
constexpr const _Tp&
get(const array<_Tp, _Nm>& __arr) noexcept
{ return __arr._M_instance[_Int]; }
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/53080] tuple interface to std::array doesn't check bounds
2012-04-23 2:15 [Bug libstdc++/53080] New: std::array - std::get() and std::tuple_element is nothing bounds check faithandbrave at gmail dot com
@ 2012-04-23 8:36 ` redi at gcc dot gnu.org
2012-04-23 10:50 ` paolo.carlini at oracle dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2012-04-23 8:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53080
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-04-23
Summary|std::array - std::get() and |tuple interface to
|std::tuple_element is |std::array doesn't check
|nothing bounds check |bounds
Ever Confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-04-23 08:35:41 UTC ---
Testcase:
#include <array>
int main()
{
typedef std::tuple_element<1, std::array<int, 1>> type;
std::array<int, 1> a;
std::get<1>(a);
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/53080] tuple interface to std::array doesn't check bounds
2012-04-23 2:15 [Bug libstdc++/53080] New: std::array - std::get() and std::tuple_element is nothing bounds check faithandbrave at gmail dot com
2012-04-23 8:36 ` [Bug libstdc++/53080] tuple interface to std::array doesn't check bounds redi at gcc dot gnu.org
@ 2012-04-23 10:50 ` paolo.carlini at oracle dot com
2012-04-23 12:28 ` paolo at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-23 10:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53080
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |paolo.carlini at oracle dot
|gnu.org |com
Target Milestone|--- |4.8.0
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-23 10:50:33 UTC ---
Ok.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/53080] tuple interface to std::array doesn't check bounds
2012-04-23 2:15 [Bug libstdc++/53080] New: std::array - std::get() and std::tuple_element is nothing bounds check faithandbrave at gmail dot com
` (2 preceding siblings ...)
2012-04-23 12:28 ` paolo at gcc dot gnu.org
@ 2012-04-23 12:28 ` paolo.carlini at oracle dot com
2012-04-23 12:32 ` faithandbrave at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-23 12:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53080
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-23 12:27:44 UTC ---
Done.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/53080] tuple interface to std::array doesn't check bounds
2012-04-23 2:15 [Bug libstdc++/53080] New: std::array - std::get() and std::tuple_element is nothing bounds check faithandbrave at gmail dot com
2012-04-23 8:36 ` [Bug libstdc++/53080] tuple interface to std::array doesn't check bounds redi at gcc dot gnu.org
2012-04-23 10:50 ` paolo.carlini at oracle dot com
@ 2012-04-23 12:28 ` paolo at gcc dot gnu.org
2012-04-23 12:28 ` paolo.carlini at oracle dot com
2012-04-23 12:32 ` faithandbrave at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-04-23 12:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53080
--- Comment #3 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-04-23 12:26:57 UTC ---
Author: paolo
Date: Mon Apr 23 12:26:43 2012
New Revision: 186702
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186702
Log:
2012-04-23 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/53080
* include/std/array (tuple_element, get): static_assert I < N.
* testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc:
New.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Likewise.
* testsuite/23_containers/array/tuple_interface/tuple_element.cc: Fix.
Added:
trunk/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/std/array
trunk/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element.cc
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/53080] tuple interface to std::array doesn't check bounds
2012-04-23 2:15 [Bug libstdc++/53080] New: std::array - std::get() and std::tuple_element is nothing bounds check faithandbrave at gmail dot com
` (3 preceding siblings ...)
2012-04-23 12:28 ` paolo.carlini at oracle dot com
@ 2012-04-23 12:32 ` faithandbrave at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: faithandbrave at gmail dot com @ 2012-04-23 12:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53080
--- Comment #5 from Akira Takahashi <faithandbrave at gmail dot com> 2012-04-23 12:32:13 UTC ---
(In reply to comment #4)
> Done.
Great thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-04-23 12:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-23 2:15 [Bug libstdc++/53080] New: std::array - std::get() and std::tuple_element is nothing bounds check faithandbrave at gmail dot com
2012-04-23 8:36 ` [Bug libstdc++/53080] tuple interface to std::array doesn't check bounds redi at gcc dot gnu.org
2012-04-23 10:50 ` paolo.carlini at oracle dot com
2012-04-23 12:28 ` paolo at gcc dot gnu.org
2012-04-23 12:28 ` paolo.carlini at oracle dot com
2012-04-23 12:32 ` faithandbrave at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).