On April 6, 2018 6:10:14 PM GMT+02:00, Jakub Jelinek <ja...@redhat.com> wrote:
>Hi!
>
>As mentioned in the PR, we ICE on the following zero sized array
>initializers, while domain is non-NULL and TYPE_MIN_VALUE is size_int
>(0),
>TYPE_MAX_VALUE is NULL and not INTEGER_CST compare_tree_int assumes it
>is.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK. 

Richard. 

>2018-04-06  Jakub Jelinek  <ja...@redhat.com>
>
>       PR debug/85252
>       * dwarf2out.c (rtl_for_decl_init): For STRING_CST initializer only
>       build CONST_STRING if TYPE_MAX_VALUE is non-NULL and is INTEGER_CST.
>
>       * gcc.dg/debug/pr85252.c: New test.
>
>--- gcc/dwarf2out.c.jj 2018-04-04 16:13:43.141551164 +0200
>+++ gcc/dwarf2out.c    2018-04-06 14:05:42.278496761 +0200
>@@ -19596,6 +19596,8 @@ rtl_for_decl_init (tree init, tree type)
>       if (is_int_mode (TYPE_MODE (enttype), &mode)
>         && GET_MODE_SIZE (mode) == 1
>         && domain
>+        && TYPE_MAX_VALUE (domain)
>+        && TREE_CODE (TYPE_MAX_VALUE (domain)) == INTEGER_CST
>         && integer_zerop (TYPE_MIN_VALUE (domain))
>         && compare_tree_int (TYPE_MAX_VALUE (domain),
>                              TREE_STRING_LENGTH (init) - 1) == 0
>--- gcc/testsuite/gcc.dg/debug/pr85252.c.jj    2018-04-06
>14:08:02.507520855 +0200
>+++ gcc/testsuite/gcc.dg/debug/pr85252.c       2018-04-06 14:07:29.200514380
>+0200
>@@ -0,0 +1,11 @@
>+/* PR debug/85252 */
>+/* { dg-do compile } */
>+
>+void
>+foo (void)
>+{
>+  static char a[0] = "";
>+  static char b[0] = "b";     /* { dg-warning "initializer-string for
>array of chars is too long" } */
>+  static char c[1] = "c";
>+  static char d[1] = "de";    /* { dg-warning "initializer-string for
>array of chars is too long" } */
>+}
>
>       Jakub

Reply via email to