https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87476

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |edlinger at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I see two options out of this.
Either don't call braced_list_to_string when processing_template_decl, defer
that only until instantiation time, like:
--- gcc/cp/typeck2.c.jj 2018-09-25 15:14:43.961258143 +0200
+++ gcc/cp/typeck2.c    2018-11-15 17:38:17.471479857 +0100
@@ -807,7 +807,8 @@ store_init_value (tree decl, tree init,
     /* Digest the specified initializer into an expression.  */
     value = digest_init_flags (type, init, flags, tf_warning_or_error);

-  if (TREE_CODE (type) == ARRAY_TYPE
+  if (!processing_template_decl
+      && TREE_CODE (type) == ARRAY_TYPE
       && TYPE_STRING_FLAG (TREE_TYPE (type))
       && TREE_CODE (value) == CONSTRUCTOR)
     value = braced_list_to_string (type, value);
The question is if there is a guarantee that store_init_value will be called
again during instantiation.

Or revert the:
@@ -1058,9 +1063,7 @@

          if (TYPE_PRECISION (typ1) == BITS_PER_UNIT)
            {
-             if (char_type != char_type_node
-                 && char_type != signed_char_type_node
-                 && char_type != unsigned_char_type_node)
+             if (char_type != char_type_node)
                {
                  if (complain & tf_error)
                    error_at (loc, "char-array initialized from wide string");
hunk of the commit, I don't really see rationale for that change.  If as in
this testcase the STRING_CST has unsigned_char_type_node as element type, it
still isn't a wide string.  One can also wonder if that
if (char_type == char_type_node)
a few lines later shouldn't be || char_type == signed_char_type_node ||
char_type == unsigned_char_type_node.

Reply via email to