valarray operator[] const - by Nicolas_Bourbaki_67

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 714853 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 12/20/2011 7:44:28 AM
Access Restriction Public


the following code should not compile

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

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

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 [lib.valarray.access] specified:

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

C++11 [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 .

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.
    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(