[Bug c++/93676] [8/9/10 Regression] crash in build_value_init

2020-02-26 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93676

--- Comment #7 from CVS Commits  ---
The master branch has been updated by Marek Polacek :

https://gcc.gnu.org/g:38e1002657828150b2cda9f80c1f752184286e80

commit r10-6872-g38e1002657828150b2cda9f80c1f752184286e80
Author: Marek Polacek 
Date:   Wed Feb 19 15:59:33 2020 -0500

c++: Fix value-init crash in template [PR93676]

Since  we
attempt to value-initialize in build_vec_init even when there's no
initializer but the type has a constexpr default constructor.  But
build_value_init doesn't work in templates, and build_vec_init
creates a lot of garbage that would not be used anyway, so don't
call it in a template.

PR c++/93676 - value-init crash in template.
* init.c (build_new_1): Don't call build_vec_init in a template.

* g++.dg/cpp0x/nsdmi-template19.C: New test.

[Bug c++/93676] [8/9/10 Regression] crash in build_value_init

2020-02-19 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93676

Marek Polacek  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #6 from Marek Polacek  ---
https://gcc.gnu.org/ml/gcc-patches/2020-02/msg01124.html

[Bug c++/93676] [8/9/10 Regression] crash in build_value_init

2020-02-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93676

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

[Bug c++/93676] [8/9/10 Regression] crash in build_value_init

2020-02-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93676

--- Comment #5 from Marek Polacek  ---
We might get away with just avoiding value-init in a template:

--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -4520,7 +4520,7 @@ build_vec_init (tree base, tree maxindex, tree init,

  We do need to keep going if we're copying an array.  */

-  if (try_const && !init)
+  if (try_const && !init && !processing_template_decl)
 /* With a constexpr default constructor, which we checked for when
setting try_const above, default-initialization is equivalent to
value-initialization, and build_value_init gives us something more

testing more...

[Bug c++/93676] [8/9/10 Regression] crash in build_value_init

2020-02-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93676

Marek Polacek  changed:

   What|Removed |Added

   Priority|P3  |P2

[Bug c++/93676] [8/9/10 Regression] crash in build_value_init

2020-02-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93676

--- Comment #4 from Marek Polacek  ---
A bit shorter test:

struct P {
  int x = 0;
};

template
struct S {
  S() { new P[2][2]; }
};

[Bug c++/93676] [8/9/10 Regression] crash in build_value_init

2020-02-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93676

--- Comment #3 from Marek Polacek  ---
We hit this assert in build_value_init:

  /* The AGGR_INIT_EXPR tweaking below breaks in templates.  */
  gcc_assert (!processing_template_decl
  || (SCALAR_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE));

because we're trying to value-initialize "struct point" in a template.

[Bug c++/93676] [8/9/10 Regression] crash in build_value_init

2020-02-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93676

Marek Polacek  changed:

   What|Removed |Added

  Known to work||4.9.4

--- Comment #2 from Marek Polacek  ---
Started with r5-7120-ga02f26f6d8162f5fe400b75d6aa2cde4c43ae86a.  Thanks for the
nice testcase.

[Bug c++/93676] [8/9/10 Regression] crash in build_value_init

2020-02-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93676

Marek Polacek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2020-02-11
 CC||mpolacek at gcc dot gnu.org
   Target Milestone|--- |8.4
Summary|crash in build_value_init   |[8/9/10 Regression] crash
   ||in build_value_init
 Ever confirmed|0   |1

--- Comment #1 from Marek Polacek  ---
Confirmed.  ICEs since GCC 5.1.