[Bug c++/94938] [10/11 Regression] internal compiler error: in value_dependent_expression_p, at cp/pt.c:26522

2020-05-06 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94938

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

https://gcc.gnu.org/g:1e89178889741c9c4d6a61e5a01c40a8a182fa68

commit r11-155-g1e89178889741c9c4d6a61e5a01c40a8a182fa68
Author: Marek Polacek 
Date:   Mon May 4 18:34:38 2020 -0400

c++: ICE in value_dependent_expression_p in C++98 mode [PR94938]

Here we ICE with -std=c++98 since the newly added call to
uses_template_parms
(r10-6357): we hit
26530 gcc_assert (cxx_dialect >= cxx11
26531 || INTEGRAL_OR_ENUMERATION_TYPE_P (type));
and TYPE is a record type.  The problem is that the argument to
value_dependent_expression_p does not satisfy potential_constant_expression
which it must, as the comment explains.  I thought about fixing this in
uses_template_parms -- only call v_d_e_p if p_c_e is true, but in this
case we want to also suppress the warnings if we don't have a constant
expression.  I couldn't simply check TREE_CONSTANT as in
compute_array_index_type_loc, because then we'd stop warning in the new
Wtype-limits3.C test.

Fixed by using type_dependent_expression_p_push instead.  This means
that we won't suppress the warnings for value-dependent expressions that
aren't type-dependent, e.g. sizeof (T).  This only seems to make a
difference for -Wdiv-by-zero, now tested in Wdiv-by-zero-3.C, where I
think it's reasonable to warn.  It could make -Wtautological-compare
warn more, but that warning doesn't trigger when it gets constant
arguments.
Wtype-limits4.C is a test reduced from poly-int.h and it tests a scenario
that was missing in our testsuite.

This patch also moves the warning_sentinels after the RECURs -- we mean
to use them for build_x_binary_op purposes only.

PR c++/94938
* pt.c (tsubst_copy_and_build): Call
type_dependent_expression_p_push
instead of uses_template_parms.  Move the warning_sentinels after
the
RECURs.

* g++.dg/warn/Wdiv-by-zero-3.C: New test.
* g++.dg/warn/Wtype-limits4.C: New test.
* g++.dg/warn/template-2.C: New test.
* g++.old-deja/g++.pt/crash10.C: Add dg-warning.

[Bug c++/94938] [10/11 Regression] internal compiler error: in value_dependent_expression_p, at cp/pt.c:26522

2020-05-04 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94938

Marek Polacek  changed:

   What|Removed |Added

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

--- Comment #3 from Marek Polacek  ---
I have a (different) patch.

[Bug c++/94938] [10/11 Regression] internal compiler error: in value_dependent_expression_p, at cp/pt.c:26522

2020-05-04 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94938

--- Comment #2 from Marek Polacek  ---
value_dependent_expression_p (called via the new uses_template_parms call)
doesn't expect a non-constant expression.  So one possible fix would be:

--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10624,7 +10624,8 @@ uses_template_parms (tree t)
   else if (t == error_mark_node)
 dependent_p = false;
   else
-dependent_p = value_dependent_expression_p (t);
+dependent_p = (potential_constant_expression (t)
+  && value_dependent_expression_p (t));

   processing_template_decl = saved_processing_template_decl;

[Bug c++/94938] [10/11 Regression] internal compiler error: in value_dependent_expression_p, at cp/pt.c:26522

2020-05-03 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94938

Martin Liška  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW
 CC||marxin at gcc dot gnu.org
   Last reconfirmed||2020-05-04

[Bug c++/94938] [10/11 Regression] internal compiler error: in value_dependent_expression_p, at cp/pt.c:26522

2020-05-03 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94938

Marek Polacek  changed:

   What|Removed |Added

 CC||jason at gcc dot gnu.org
Summary|internal compiler error: in |[10/11 Regression] internal
   |value_dependent_expression_ |compiler error: in
   |p, at cp/pt.c:26522 |value_dependent_expression_
   ||p, at cp/pt.c:26522
   Keywords||ice-on-valid-code
   Target Milestone|--- |10.0

--- Comment #1 from Marek Polacek  ---
Started with r10-6357-g4dd468a042e19ef0fdbb1c53ca4060d4cb4972c5