Bug in VC++ 2010 with global refence to array - by Olecorp

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 679716 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 7/17/2011 11:24:34 PM
Access Restriction Public


It seems, VC++ 2010 have bug with global references to arrays.
Got strange results with this code with VC++ 2010 - compiles, but gives wrong results.
Tested with C++Builder 2010 and GCC 4.2.4 (on linux) - works just fine.

#include <stdio.h>

// Simple data
int IntArr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

// Pointer to simple data
int (*IntArrPtr)[10] = &IntArr;

// Reference #1 to pointed data
int (&IntArrRef1)[10] = *IntArrPtr;

int main(int argc, const char* argv[])
	// Reference #2 to pointed data
	int (&IntArrRef2)[10] = *IntArrPtr;

	printf("Data from IntArrRef1: ");
	for (int i = 0; i < 10; i++)
		printf(" %d ", IntArrRef1[i]);

	printf("Data from IntArrRef2: ");
	for (int i = 0; i < 10; i++)
		printf(" %d ", IntArrRef2[i]);
	return 0;
Sign in to post a comment.
Posted by Microsoft on 8/19/2011 at 3:55 PM
Sorry, we cannot comment on release schedules.

Andy Rich
Visual C++ QA
Posted by Olecorp on 7/27/2011 at 3:10 PM
Oh, great! When a new release will be released?
Posted by Microsoft on 7/27/2011 at 1:05 PM
    A fix for this issue has been checked into the compiler sources. The fix should show up in the next release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by MS-Moderator08 [Feedback Moderator] on 7/18/2011 at 2:07 AM
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 7/17/2011 at 11:49 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)