[Bug c++/56567] [4.8 Regression] ICE with lambda return type deduction and braced-init-list
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56567 --- Comment #6 from Jason Merrill jason at gcc dot gnu.org 2013-03-11 16:22:28 UTC --- Author: jason Date: Mon Mar 11 16:22:16 2013 New Revision: 196600 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=196600 Log: PR c++/56567 * typeck.c (check_return_expr): Disallow returning init list here. * semantics.c (apply_deduced_return_type): Not here. Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/semantics.c trunk/gcc/cp/typeck.c trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist3.C
[Bug c++/56567] [4.8 Regression] ICE with lambda return type deduction and braced-init-list
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56567 --- Comment #7 from David Krauss potswa at mac dot com 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() } } );
[Bug c++/56567] [4.8 Regression] ICE with lambda return type deduction and braced-init-list
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56567 --- Comment #8 from David Krauss potswa at mac dot com 2013-03-11 22:51:12 UTC --- Oops, I didn't see the preceding comment checkin before submitting that. Maybe that's a better place to check, but we might keep the extra test cases. Make sure that the remaining ICE is gone.
[Bug c++/56567] [4.8 Regression] ICE with lambda return type deduction and braced-init-list
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56567 --- Comment #5 from Jason Merrill jason at gcc dot gnu.org 2013-03-11 03:21:52 UTC --- (In reply to comment #4) It's certainly legal to compile a function returning an std::initializer list, which is never called. So this fix is problematic. For example []{ return std::initializer_list int { 1, 2 }; }(); That's a good point, though returning an initializer_list value is completely useless; since the underlying array is local to the returning function, any use of the returned value would cause undefined behavior, just like returning a reference to a local variable.
[Bug c++/56567] [4.8 Regression] ICE with lambda return type deduction and braced-init-list
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56567 --- Comment #4 from David Krauss potswa at mac dot com 2013-03-10 02:18:18 UTC --- Note, there is nothing in the Standard to prohibit return of an initializer_list value, so this rejects programs which are conformant. Unless/until #56568 is resolved, doing so results in UB (whether or not that's a bug). That's only if the function is executed. It's certainly legal to compile a function returning an std::initializer list, which is never called. So this fix is problematic. For example []{ return std::initializer_list int { 1, 2 }; }(); Not filing another report yet because I haven't pulled the changes and tested anything for myself.
[Bug c++/56567] [4.8 Regression] ICE with lambda return type deduction and braced-init-list
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56567 Jakub Jelinek jakub at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2013-03-08 CC||jakub at gcc dot gnu.org, ||jason at gcc dot gnu.org Target Milestone|--- |4.8.0 Summary|ICE with lambda return type |[4.8 Regression] ICE with |deduction and |lambda return type |braced-init-list|deduction and ||braced-init-list Ever Confirmed|0 |1 --- Comment #1 from Jakub Jelinek jakub at gcc dot gnu.org 2013-03-08 08:42:43 UTC --- Started with http://gcc.gnu.org/viewcvs?root=gccview=revrev=185768
[Bug c++/56567] [4.8 Regression] ICE with lambda return type deduction and braced-init-list
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56567 --- Comment #2 from Jason Merrill jason at gcc dot gnu.org 2013-03-08 15:55:28 UTC --- Author: jason Date: Fri Mar 8 15:55:18 2013 New Revision: 196548 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=196548 Log: PR c++/56567 * semantics.c (apply_deduced_return_type): Don't allow returning std::initializer_list. Added: trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist3.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/semantics.c
[Bug c++/56567] [4.8 Regression] ICE with lambda return type deduction and braced-init-list
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56567 Jason Merrill jason at gcc dot gnu.org changed: What|Removed |Added Status|NEW |RESOLVED Resolution||FIXED AssignedTo|unassigned at gcc dot |jason at gcc dot gnu.org |gnu.org | --- Comment #3 from Jason Merrill jason at gcc dot gnu.org 2013-03-08 16:13:53 UTC --- Fixed.