std::arrayに対するstd::tuple_elementの特殊化で、境界チェックが行われていない - by Akira Takahashi

Status : 

 


1
0
Sign in
to vote
ID 738181 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 4/22/2012 7:25:04 PM
Access Restriction Public

Description

C++11規格の23.3.2.9 Tuple interface to class template arrayには、std::arrayに対するstd::tuple_elementとstd::get()について、以下のような仕様があります。

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.

Visual C++ 2010には、これらの仕様のうち、std::get()では境界チェックが行われていますが、std::tuple_elementについては境界チェックが行われていません。
std::get()と同様に、static_assertによる境界チェックを行う必要があります。
Sign in to post a comment.
Posted by Deon [MSFT] on 4/29/2014 at 12:25 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from: http://go.microsoft.com/?linkid=9832436
Posted by James [MSFT] on 11/29/2012 at 1:44 PM
Hello,

Thanks for reporting the bug. We've fixed it, and the fix will be available in the next release of our C++ Standard Library implementation.

Note: Connect doesn’t notify me about comments; if you have further questions, please feel free to e-mail me.

James McNellis
Visual C++ Libraries
james.mcnellis@microsoft.com
Posted by Microsoft on 5/7/2012 at 1:30 AM
この度はフィードバックをお送りいただき、誠にありがとうございます。 現在、お送りいただきました報告内容に基づき問題を確認中ですので、しばらくお待ちください。 よろしくお願いいたします。

[Problem Description]:
In the C++11 standard's 23.3.2.9 Tuple interface to class template array, there is the following specification regarding the std::tuple_element and std::get() for std::array. tuple_element >::type Requires: I T& get(array& a) noexcept; Requires: I

[Repro Steps]:
Compile the following program:
#include <array>
int main ()
{
typedef std::tuple_element<3, std::array<int, 2>>::type type;
}

[Actual Results]:
The program can be compiled.

[Expected Results]:
The program ill-formed and a compile error is caused.
The program can be compiled.
The program ill-formed and a compile error is caused.
Posted by MS-Moderator01 on 4/22/2012 at 7:47 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)