@@ -522,6 +522,7 @@ build_target_expr (tree decl, tree value, tsubst_flags_t complain)
if (CP_TYPE_CONST_NON_VOLATILE_P (type)
&& !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type)
&& !VOID_TYPE_P (TREE_TYPE (value))
+ && !TYPE_HAS_MUTABLE_P (type)
&& reduced_constant_expression_p (value))
TREE_READONLY (decl) = true;
new file mode 100644
@@ -0,0 +1,18 @@
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -fdump-tree-gimple }
+// { dg-final { scan-tree-dump-not {static const struct S} "gimple" } }
+
+// Test that mutable prevents putting this init-list array in rodata.
+
+#include <initializer_list>
+
+struct S {
+ constexpr S(int i) : i(i) {}
+ mutable int i;
+};
+
+void f(std::initializer_list<S>);
+
+int main() {
+ f({1,2,3});
+}