[Bug c++/89119] [7/8/9/ Regression] internal compiler error: in tsubst_copy with RANGE_EXPR

2019-01-30 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89119

--- Comment #7 from Marek Polacek  ---
Author: mpolacek
Date: Wed Jan 30 19:04:05 2019
New Revision: 268400

URL: https://gcc.gnu.org/viewcvs?rev=268400=gcc=rev
Log:
PR c++/89119 - ICE with value-initialization in template.
* pt.c (tsubst_copy_and_build): Handle RANGE_EXPR.

* g++.dg/cpp0x/initlist-value3.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/cpp0x/initlist-value3.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/pt.c
trunk/gcc/testsuite/ChangeLog

[Bug c++/89119] [7/8/9/ Regression] internal compiler error: in tsubst_copy with RANGE_EXPR

2019-01-30 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89119

Marek Polacek  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #6 from Marek Polacek  ---
https://gcc.gnu.org/ml/gcc-patches/2019-01/msg01735.html

[Bug c++/89119] [7/8/9/ Regression] internal compiler error: in tsubst_copy with RANGE_EXPR

2019-01-30 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89119

Marek Polacek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2019-01-30
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org
 Ever confirmed|0   |1

[Bug c++/89119] [7/8/9/ Regression] internal compiler error: in tsubst_copy with RANGE_EXPR

2019-01-30 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89119

--- Comment #5 from Jakub Jelinek  ---
There are only a couple of spots that build this:
constexpr.c:e.index = build2 (RANGE_EXPR, sizetype, new_lo,
hi);
constexpr.c:  tree range = build2 (RANGE_EXPR, size_type_node,
init.c: ce.index = build2 (RANGE_EXPR, sizetype, size_zero_node,
init.c: ce.index = build2 (RANGE_EXPR, sizetype, size_zero_node,
max_index);
init.c: field = build2 (RANGE_EXPR, sizetype, field,
typeck2.c:  tree range = build2 (RANGE_EXPR, size_type_node,
As you can see, all of them are sizetype or size_type_node and the operands
should be really the same type.  Several of them assert that what they are
building the RANGE_EXPR with is INTEGER_CST, other spots use size_int () or
similar to construct those INTEGER_CSTs.  In any case, RANGE_EXPRs make only
sense with constant ranges, for anything else there should be runtime loop
initializing it, and they are about array indexes, which is something expressed
in sizetype.

[Bug c++/89119] [7/8/9/ Regression] internal compiler error: in tsubst_copy with RANGE_EXPR

2019-01-30 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89119

--- Comment #4 from Marek Polacek  ---
Aha -- I thought the RANGE_EXPR could have something value-dependent, but as
this shows, it's not the case:

struct S { int a[4]; };

template
struct R { int a[N]; };

template 
void
fn ()
{
  constexpr auto s = S();
  constexpr auto r = R<4>();
}

void
foo ()
{
  fn();
}

[Bug c++/89119] [7/8/9/ Regression] internal compiler error: in tsubst_copy with RANGE_EXPR

2019-01-30 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89119

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek  ---
I believe all RANGE_EXPRs pt.c should see are with two INTEGER_CSTs with
non-dependent type, so just return t; IMHO would do the job.  But if you want
to recurse on those constants and build a new RANGE_EXPR, that is certainly
possible too.

[Bug c++/89119] [7/8/9/ Regression] internal compiler error: in tsubst_copy with RANGE_EXPR

2019-01-30 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89119

--- Comment #2 from Marek Polacek  ---
We'll probably have to handle RANGE_EXPR in tsubst_expr; I can try that.

[Bug c++/89119] [7/8/9/ Regression] internal compiler error: in tsubst_copy with RANGE_EXPR

2019-01-30 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89119

Marek Polacek  changed:

   What|Removed |Added

   Keywords||ice-on-valid-code
   Target Milestone|--- |7.5
Summary|internal compiler error: in |[7/8/9/ Regression]
   |tsubst_copy with RANGE_EXPR |internal compiler error: in
   ||tsubst_copy with RANGE_EXPR

--- Comment #1 from Marek Polacek  ---
Started with r166167.