From 7d510a821a48a208b224a0f5e73fb2a3e48a583e Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 2 Jan 2012 16:15:49 +0000 Subject: re PR c++/20140 (template function complains about "char-array initialized from wide string") /cp 2012-01-02 Paolo Carlini PR c++/20140 * typeck2.c (digest_init_r): Use copy_init when initializing an array of chars. /testsuite 2012-01-02 Paolo Carlini PR c++/20140 * g++.dg/template/init9.C: New. From-SVN: r182805 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/typeck2.c | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'gcc/cp') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c602721..7b91727 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-01-02 Paolo Carlini + + PR c++/20140 + * typeck2.c (digest_init_r): Use copy_init when initializing + an array of chars. + 2012-01-01 Paolo Carlini PR c++/16603 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 4648e75..a1b4274 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -902,7 +902,11 @@ digest_init_r (tree type, tree init, bool nested, int flags, } } - TREE_TYPE (init) = type; + if (type != TREE_TYPE (init)) + { + init = copy_node (init); + TREE_TYPE (init) = type; + } if (TYPE_DOMAIN (type) != 0 && TREE_CONSTANT (TYPE_SIZE (type))) { int size = TREE_INT_CST_LOW (TYPE_SIZE (type)); -- cgit v1.1