Bug 47212 - [C++0x] crash on lambda returning lambda
Summary: [C++0x] crash on lambda returning lambda
Status: RESOLVED DUPLICATE of bug 47687
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-01-07 14:48 UTC by a71104
Modified: 2011-05-27 17:24 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.5.2, 4.6.0
Last reconfirmed: 2011-01-07 15:00:27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description a71104 2011-01-07 14:48:34 UTC
Here's the code:



==============================================

#include <iostream>
using namespace std;

auto test = [] () {
	return [] (istream &ris) -> istream& {
		return ris;
	};
};

int main() {
	cin >> test();
	return 0;
}

==============================================



I'm not sure whether this code is correct but it just crashes g++ 4.5.0.
I'm compiling with:

g++ -std=c++0x -pedantic -Wall Test.cpp



I'm doing code like that because I wish to implement a custom parameterized I/O manipulator without using implementation-specific types such as smanip and stuff.
Note that it doesn't crash if I just call test() without using the result on cin, thus I think the problem is matching the returned lambda against the version of operator >> that takes a function as an argument.

PS: I don't think there's any difference but I'm using MinGW and I'm currently unable to test on Linux with real g++.
Comment 1 Jonathan Wakely 2011-01-07 15:00:27 UTC
fails on Linux too, it's not a target-specific problem
Comment 2 Jason Merrill 2011-05-27 17:24:48 UTC
I'm looking at this issue.

*** This bug has been marked as a duplicate of bug 47687 ***