From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5033 invoked by alias); 11 Mar 2013 22:43:21 -0000 Received: (qmail 4929 invoked by uid 48); 11 Mar 2013 22:42:47 -0000 From: "potswa at mac dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/56567] [4.8 Regression] ICE with lambda return type deduction and braced-init-list Date: Mon, 11 Mar 2013 22:43:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: potswa at mac dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jason at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.0 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-03/txt/msg00903.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56567 --- Comment #7 from David Krauss 2013-03-11 22:42:46 UTC --- Created attachment 29647 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29647 alternative fix Yes. However, the above fix doesn't catch all instances of doing so; for example []() -> std::initializer_list< int >{ return { 1, 2 }; } Worse, one case still results in ICE []() { return std::initializer_list< int >{ 1, 2 }; } Here's an improved fix. It doesn't attempt to catch runtime UB. I think that should be another warning diagnostic, which can also flag such attempted workarounds as reference return types []() -> std::initializer_list< int > && { return { 1, 2 }; } Users are likely to try fiddling after we flag their initial attempt, so we might as well be as broad as possible. However, a specialization of std::min can return a valid std::initializer_list< T > const & : struct s { friend bool operator < ( s lhs, s rhs ) { return false; } friend bool operator < ( std::initializer_list< s > lhs, std::initializer_list< s > rhs ) { return std::lexicographical_compare( lhs.begin(), lhs.end(), rhs.begin(), rhs.end() ); } }; std::min( std::initializer_list< std::initializer_list< s > > { { s(), s(), s() }, { s(), s() } } );