diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index 8e4cfae08aa..258cfd43114 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -9213,6 +9213,8 @@ cp_build_c_cast (location_t loc, tree type, tree expr, maybe_warn_about_useless_cast (loc, type, value, complain); maybe_warn_about_cast_ignoring_quals (loc, type, complain); } + else if (complain & tf_error) + build_const_cast_1 (loc, type, value, tf_error, &valid_p); return result; } @@ -9248,7 +9250,7 @@ cp_build_c_cast (location_t loc, tree type, tree expr, to succeed. */ if (!same_type_p (non_reference (type), non_reference (result_type))) { - result = build_const_cast_1 (loc, type, result, false, &valid_p); + result = build_const_cast_1 (loc, type, result, tf_none, &valid_p); gcc_assert (valid_p); } return result; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array20.C b/gcc/testsuite/g++.dg/cpp0x/initlist-array20.C new file mode 100644 index 00000000000..048c5b45652 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-array20.C @@ -0,0 +1,11 @@ +// PR c++/112658 +// PR c++/94264 +// { dg-do compile { target c++11 } } + +void f(int*); + +int main() { + using array = int[]; + f(array{42}); + f((int*)array{42}); +}