Search

fatal error C1001: An internal error has occurred in the compiler in C++11 construction "for (int n : <temp object>)" by _lee

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 744341
Opened: 5/27/2012 1:15:30 PM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
0
User(s) can reproduce this bug
Following C++11 code crashes the VC compiler, but successfully compiled by GCC.

(the code is not correct semantically, because scope of temporary objects is not defined for "FOR IN" statement)
Details (expand)

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

Visual Studio 11 Beta

Steps to reproduce

#include <vector>
using namespace std;

struct A {
    vector<int> v;

    const vector<int>& a() { return v; }
};

int main(int argc, const char *argv[]) {
    for (int n : A().a()) {
    }
}

Product Language

English

Operating System

Windows 8

Operating System Language

English

Actual results

a.cpp(13) : fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\utc\src\p2\ehexcept.c', line 965)
To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information

Expected results

Some error message about temporary object scope.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 5/29/2012 at 10:46 AM
We have fixed the problem in the compiler. And the fix will be included in our upcoming major product release.

Thanks for the bug report.
Posted by MS-Moderator08 [Feedback Moderator] on 5/28/2012 at 12:54 AM
Thank you for submitting feedback on Visual Studio 11 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 5/27/2012 at 1:42 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.