Home Dashboard Directory Help
Search

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


Status: 

Closed
 as Fixed Help for as Fixed


1
0
Sign in
to vote
Type: Bug
ID: 679716
Opened: 7/17/2011 11:24:34 PM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

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("\r\n");

    printf("Data from IntArrRef2: ");
    for (int i = 0; i < 10; i++)
    {
        printf(" %d ", IntArrRef2[i]);
    }
    printf("\r\n");
    
    return 0;
}
Details
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
Hi:
    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)
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
Test01.cpp 7/17/2011 939 bytes