Search

auto compiler error with multiple name declaration by G M Sanders

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 698688
Opened: 11/3/2011 12:43:52 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
0
User(s) can reproduce this bug
The following code snippet fails to compile:

    int a[] = {0,1,2,3,4,5,6,7,8,9};
    auto b=std::begin(a), e=std::end(a);

1> ... error C3538: in a declarator-list 'auto' must always deduce to the same type
1>         could be 'int *'
1>         or     'int *'

However, this works:

    int a[] = {0,1,2,3,4,5,6,7,8,9};
    auto b=std::begin(a);
    auto e=std::end(a);

This was originally submitted to the c++ user group at comp.lang.c++.moderated and it was concluded that this is a compiler bug.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling version

Visual Studio 2010 SP1

Steps to reproduce

Compile the following:

#include <iterator>    

void main()
{
     int a[] = {0,1,2,3,4,5,6,7,8,9};
     auto b=std::begin(a), e=std::end(a);
}

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

1> ... error C3538: in a declarator-list 'auto' must always deduce to the same type
1>         could be 'int *'
1>         or     'int *'

Expected results

The program to compiler without error.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 11/3/2011 at 5:16 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 11/3/2011 at 2:16 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 11/3/2011 at 1:48 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.