Search

internal compiler error instead of compiler diagnostic by Aidtopia

Closed
as Fixed Help for as Fixed

2
0
Sign in
to vote
Type: Bug
ID: 736931
Opened: 4/14/2012 12:02:57 PM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
1
User(s) can reproduce this bug
I made an error converting a traditional for loop to a std::for_each with a lambda. Instead of getting diagnostics pointing out the error, the compiler failed with an internal compiler error. I've reduced the problem to a complete but small sample that reproduces the issue.

This is not a blocking issue, as correcting the source code avoids the internal compiler error, but perhaps this is a mild symptom of a more serious problem. Also, without the compiler diagnostic, the error can be tough to spot. Intellisense doesn't seem to know about lambda capture rules, so there are no red squiggles pointing out the error.
Details (expand)

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

Visual Studio 2010 SP1

Steps to reproduce

// This is broken code that demonstrates an internal compiler error in Visual
// Studio 2010's C++ compiler.

#include <algorithm>
#include <iterator>
#include <string>

// The following function should not compile because it attempts to reference
// an object inside the lambda that is not captured. I'd expect compiler
// diagnostics, but it actually triggers and internal compiler error.
void Foo() {
    static const struct TestCase {
        char input[32];
        char output[32];
    } tests[] = {
        { "0", "zero" },
        { "1", "one" }
    };
    std::for_each(std::begin(tests), std::end(tests), [](const TestCase &t) {
        const TestCase &t0 = tests[0]; // triggers internal compiler error
    });
}

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

Internal compiler error

Expected results

A diagnostic pointing out that the object tests is not visible inside the lambda.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 4/16/2012 at 11:41 AM
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 4/15/2012 at 6:41 PM
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.
Sign in to post a workaround.