recursive trailing return types visual studio 2010 - by philrosenberg

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 723213 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 2/3/2012 2:39:36 PM
Access Restriction Public


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; 
    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); 
    decltype(mydoublevect2d+myintvect2d) myothervect2d; 
    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.
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(