typeck2.c (digest_init_r): Fix overlength strings.
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Thu, 13 Sep 2018 18:43:44 +0000 (18:43 +0000)
committerJeff Law <law@gcc.gnu.org>
Thu, 13 Sep 2018 18:43:44 +0000 (12:43 -0600)
* typeck2.c (digest_init_r): Fix overlength strings.
* vtable-class-hierarchy.c (build_key_buffer_arg): Make string literal
NUL terminated.

From-SVN: r264286

gcc/cp/ChangeLog
gcc/cp/typeck2.c

index ca8939d9a087489277c6711cdf0c98431192c117..8ba87ce3894371146c36da3664af2d0675669ec2 100644 (file)
@@ -1,3 +1,9 @@
+2018-09-13  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       * typeck2.c (digest_init_r): Fix overlength strings.
+       * vtable-class-hierarchy.c (build_key_buffer_arg): Make string literal
+       NUL terminated.
+
 2018-09-13  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        PR c++/87093
index 7cd0a7ef4b48035cd737cd7439e7945514e4d8e4..b13ed2660dee51fe2c5eb8fd99c351d7c364fbbb 100644 (file)
@@ -1112,8 +1112,13 @@ digest_init_r (tree type, tree init, int nested, int flags,
                 counted in the length of the constant, but in C++ this would
                 be invalid.  */
              if (size < TREE_STRING_LENGTH (init))
-               permerror (loc, "initializer-string for array "
-                          "of chars is too long");
+               {
+                 permerror (loc, "initializer-string for array "
+                            "of chars is too long");
+
+                 init = build_string (size, TREE_STRING_POINTER (init));
+                 TREE_TYPE (init) = type;
+               }
            }
          return init;
        }