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

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

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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Jason/Jonathan, is that true?  What exactly shall be the qualification in the
array case?  Ored type quals of the initializer's element type and provided
quals from the structured binding declaration?  If so, it would be something
like:
--- gcc/cp/pt.c.jj      2018-06-04 15:47:24.633937198 +0200
+++ gcc/cp/pt.c 2018-06-05 09:12:56.151035636 +0200
@@ -26734,10 +26734,15 @@ do_auto_deduction (tree type, tree init,
       && auto_node == type
       && init != error_mark_node
       && TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE)
-    /* [dcl.decomp]/1 - if decomposition declaration has no ref-qualifiers
-       and initializer has array type, deduce cv-qualified array type.  */
-    return cp_build_qualified_type_real (TREE_TYPE (init), TYPE_QUALS (type),
-                                        complain);
+    {
+      /* [dcl.decomp]/1 - if decomposition declaration has no ref-qualifiers
+        and initializer has array type, deduce cv-qualified array type.  */
+      int type_quals = TYPE_QUALS (type);
+      tree eltype = strip_array_types (TREE_TYPE (init));
+      type_quals |= TYPE_QUALS (eltype);
+      return cp_build_qualified_type_real (TREE_TYPE (init), type_quals,
+                                          complain);
+    }
   else if (AUTO_IS_DECLTYPE (auto_node))
     {
       bool id = (DECL_P (init)

Reply via email to