[Bug c++/93275] [9/10 Regression] ICE: unexpected expression 'N' of kind template_parm_index

2020-01-21 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93275

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||jakub at gcc dot gnu.org
 Resolution|--- |DUPLICATE

--- Comment #7 from Jakub Jelinek  ---
Dup.

*** This bug has been marked as a duplicate of bug 93279 ***

[Bug c++/93275] [9/10 Regression] ICE: unexpected expression 'N' of kind template_parm_index

2020-01-21 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93275

--- Comment #6 from Martin Liška  ---
(In reply to Marek Polacek from comment #5)
> (In reply to Martin Liška from comment #3)
> > Confirmed, started with r9-6404-g1ce59b6cad83d5ca6f1efee83f910d8b677a976a.
> 
> Are you sure?  It's only a daily bump.

Sorry, it's the commit right after it:
r9-6405-gbddee796d0b4800b5ac3d7e7e9e315c23799424d

For named function calls in a template, the result of unqualified lookup is
safed in CALL_EXPR_FN.  But for operator expressions, no unqualified lookup
is performed until we know whether the operands have class type.  So when we
see in a lambda a use of an operator that might be overloaded, we need to do
that lookup then and save it away somewhere.  One possibility would be in
the expression, but we can't really add extra conditional operands to
standard tree codes.  I mostly implemented another approach using a new
WITH_LOOKUP_EXPR code, but teaching everywhere how to handle a new tree code
is always complicated.  Then it occurred to me that we could associate the
lookups with the function, which is both simpler and smaller.  So this patch
stores any operator bindings needed by a lambda function in an internal
attribute on the lambda call operator.

* name-lookup.c (op_unqualified_lookup)
(maybe_save_operator_binding, discard_operator_bindings)
(push_operator_bindings): New.
* typeck.c (build_x_binary_op, build_x_unary_op): Call
maybe_save_operator_binding.
* decl.c (start_preparsed_function): Call push_operator_bindings.
* tree.c (cp_free_lang_data): Call discard_operator_bindings.

From-SVN: r269477

[Bug c++/93275] [9/10 Regression] ICE: unexpected expression 'N' of kind template_parm_index

2020-01-20 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93275

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #5 from Marek Polacek  ---
(In reply to Martin Liška from comment #3)
> Confirmed, started with r9-6404-g1ce59b6cad83d5ca6f1efee83f910d8b677a976a.

Are you sure?  It's only a daily bump.

[Bug c++/93275] [9/10 Regression] ICE: unexpected expression 'N' of kind template_parm_index

2020-01-20 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93275

--- Comment #4 from Martin Liška  ---
Reduced test-case:

$ cat pr93275.ii
template  struct A { static constexpr int value = __v; };
template  struct B;
template  struct B { typedef _Tp type; };
template 
using enable_if_t = typename B<_Cond, _Tp>::type;
template  constexpr bool array_depth_v = A<1>::value;
template  struct C {
  template , decltype(nullptr)> = nullptr>
  void operator*(Other other) {
[other](T t) { t *other; };
  }
};

int
main() {
  C, 1> a0;
  a0 * 4.f;
  return 0;
}

$ g++ -c pr93275.ii -std=c++17
pr93275.ii: In substitution of ‘template >
template > >,
std::nullptr_t>::type  > void C >::operator*(Other)
[with Other = ; typename B > >,
std::nullptr_t>::type  = ; T = float; int  =
]’:
pr93275.ii:11:22:   required from ‘void C >::operator*(Other)
[with Other = float; typename B > >,
std::nullptr_t>::type  = nullptr; T = C; int  =
1]’
pr93275.ii:18:8:   required from here
pr93275.ii:9:25: internal compiler error: unexpected expression ‘’
of kind template_parm_index
9 | enable_if_t, decltype(nullptr)> = nullptr>
  | ^~~~
0x961234 cxx_eval_constant_expression
/home/marxin/Programming/gcc/gcc/cp/constexpr.c:6125
0x96174e cxx_eval_outermost_constant_expr
/home/marxin/Programming/gcc/gcc/cp/constexpr.c:6323
0x9660a4 maybe_constant_value(tree_node*, tree_node*, bool)
/home/marxin/Programming/gcc/gcc/cp/constexpr.c:6593
0xa96124 convert_nontype_argument
/home/marxin/Programming/gcc/gcc/cp/pt.c:7116
0xa96124 convert_template_argument
/home/marxin/Programming/gcc/gcc/cp/pt.c:8350
0xa96124 convert_template_argument
/home/marxin/Programming/gcc/gcc/cp/pt.c:8087
0xa9796b coerce_template_parms
/home/marxin/Programming/gcc/gcc/cp/pt.c:8829
0xabce39 lookup_template_class_1
/home/marxin/Programming/gcc/gcc/cp/pt.c:9666
0xabce39 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
/home/marxin/Programming/gcc/gcc/cp/pt.c:10038
0xab88cf tsubst_aggr_type
/home/marxin/Programming/gcc/gcc/cp/pt.c:13332
0xab0d3f tsubst(tree_node*, tree_node*, int, tree_node*)
/home/marxin/Programming/gcc/gcc/cp/pt.c:15033
0xab856b tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
/home/marxin/Programming/gcc/gcc/cp/pt.c:13125
0xaab074 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
/home/marxin/Programming/gcc/gcc/cp/pt.c:18999
0xa9f3b7 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/marxin/Programming/gcc/gcc/cp/pt.c:18590
0xab2c53 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/marxin/Programming/gcc/gcc/cp/pt.c:12047
0xab2c53 tsubst_template_arg(tree_node*, tree_node*, int, tree_node*)
/home/marxin/Programming/gcc/gcc/cp/pt.c:12058
0xab2c53 tsubst_template_arg(tree_node*, tree_node*, int, tree_node*)
/home/marxin/Programming/gcc/gcc/cp/pt.c:12046
0xab856b tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
/home/marxin/Programming/gcc/gcc/cp/pt.c:13125
0xab88aa tsubst_aggr_type
/home/marxin/Programming/gcc/gcc/cp/pt.c:13326
0xab08f5 tsubst(tree_node*, tree_node*, int, tree_node*)
/home/marxin/Programming/gcc/gcc/cp/pt.c:15662
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug c++/93275] [9/10 Regression] ICE: unexpected expression 'N' of kind template_parm_index

2020-01-20 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93275

Martin Liška  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
  Known to work||8.3.0
   Keywords||ice-on-valid-code
   Last reconfirmed||2020-01-20
 CC||jason at gcc dot gnu.org,
   ||marxin at gcc dot gnu.org
 Ever confirmed|0   |1
Summary|internal compiler error:|[9/10 Regression] ICE:
   |unexpected expression 'N'   |unexpected expression 'N'
   |of kind template_parm_index |of kind template_parm_index
   Target Milestone|--- |9.3
  Known to fail||10.0, 9.2.0

--- Comment #3 from Martin Liška  ---
Confirmed, started with r9-6404-g1ce59b6cad83d5ca6f1efee83f910d8b677a976a.