Home Dashboard Directory Help
Search

valarray operator[] const by Nicolas_Bourbaki_67


Status: 

Closed
 as Fixed Help for as Fixed


2
0
Sign in
to vote
Type: Bug
ID: 714853
Opened: 12/20/2011 7:44:28 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

the following code should not compile

#include "stdafx.h"
#include <valarray>


int _tmain(int argc, _TCHAR* argv[])
{
    const std::valarray<int> v(1, 1);
    v[0]=10;
    return 0;
}
Details
Sign in to post a comment.
Posted by Microsoft on 1/18/2012 at 8:21 PM
Hi,

Thanks for reporting this bug. We've fixed it, and the fix will be available in VC11.

Interestingly, this changed between C++03 and C++11.

C++03 26.3.2.3 [lib.valarray.access] specified:

T operator[](size_t) const;
T& operator[](size_t);

C++11 26.6.2.4 [valarray.access] specifies:

const T& operator[](size_t) const;
T& operator[](size_t);

We now follow C++11.

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by aljodAv on 12/28/2011 at 11:28 AM
I have to reconsider: *This is a bug*, because the variable is declared const!

Sorry for not having noted the const keyword!
Posted by aljodAv on 12/28/2011 at 11:08 AM
I don't see any bug:

const std::valarray<int> v(1, 1);
    the 1st argument is a correct *const Type&* and the 2nd is a correct *size_t* value.
v[0]=10;
    the attribution is correct.
Posted by MS-Moderator10 [Feedback Moderator] on 12/20/2011 at 10:30 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 12/20/2011 at 8:43 AM
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)
Sign in to post a workaround.