Home Dashboard Directory Help
Search

recursive trailing return types visual studio 2010 by philrosenberg


Status: 

Closed
 as Fixed Help for as Fixed


2
0
Sign in
to vote
Type: Bug
ID: 723213
Opened: 2/3/2012 2:39:36 PM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
view
1
User(s) can reproduce this bug

Description

The following legal C++11 code which utilises a recursive trailing return type function causes the VC++ compiler to crash

#include <vector>
#include <iostream>

template<class T, class U>
inline auto operator+(const std::vector<T> &a, const std::vector<U> &b)
-> std::vector<decltype(T()+U())>
{
    std::vector<decltype(T()+U())> result;
    result.resize(std::min(a.size(),b.size()));
    for(unsigned int i=0; i<result.size(); ++i) result[i]=a[i]+b[i];
    return result;
}

int main()
{
    std::vector<std::vector<double> > mydoublevect2d(1);
    std::vector<std::vector<int> > myintvect2d(1);
    mydoublevect2d.resize(1);
    myintvect2d.resize(1);
    mydoublevect2d[0].push_back(1.0);
    myintvect2d[0].push_back(1);
    decltype(mydoublevect2d+myintvect2d) myothervect2d;
    myothervect2d=mydoublevect2d+myintvect2d;
    std::cout << myothervect2d[0][0];
    return 0;
}

The error given is

fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'msc1.cpp', line 1420)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1> Please choose the Technical Support command on the Visual C++
1> Help menu, or open the Technical Support help file for more information


Changing the function from an overload of operator+ to a function called add does not fix the problem.
Details
Sign in to post a comment.
Posted by Microsoft on 2/6/2012 at 11:46 AM
Thank you for your report.

This issue has been fixed in the upcoming version of Visual Studio and the fix should be available in the public Beta release.

Marian Luparu,
Visual C++
Posted by MS-Moderator07 [Feedback Moderator] on 2/5/2012 at 6:43 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by MS-Moderator01 on 2/3/2012 at 3:45 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.