commit 10c6627ac3371930fe44868ad94cb2ebc9d4e908
Author: Jason Merrill <jason@redhat.com>
Date: Fri Mar 8 10:25:55 2013 -0500
PR c++/56567
* semantics.c (apply_deduced_return_type): Don't allow returning
std::initializer_list.
@@ -9061,6 +9061,12 @@ apply_deduced_return_type (tree fco, tree return_type)
if (return_type == error_mark_node)
return;
+ if (is_std_init_list (return_type))
+ {
+ error ("returning %qT", return_type);
+ return_type = void_type_node;
+ }
+
if (LAMBDA_FUNCTION_P (fco))
{
tree lambda = CLASSTYPE_LAMBDA_EXPR (current_class_type);
new file mode 100644
@@ -0,0 +1,11 @@
+// PR c++/56567
+// { dg-require-effective-target c++11 }
+
+#include <initializer_list>
+
+int main()
+{
+ []{ return { 1, 2 }; }(); // { dg-error "initializer_list" }
+}
+
+// { dg-prune-output "return-statement with a value" }