[Bug c++/88795] ICE on class-template argument deduction if non-type parameter has indirection

2019-02-14 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88795

--- Comment #6 from David Malcolm  ---
Author: dmalcolm
Date: Thu Feb 14 23:14:56 2019
New Revision: 268915

URL: https://gcc.gnu.org/viewcvs?rev=268915=gcc=rev
Log:
Fix ICE on class-template argument deduction (PR c++/88795)

PR c++/88795 reports an ICE building a function_type for a deduction guide
when the substitution into the function signature fails, due to an
error_mark_node being returned from tsubst_arg_types but not being checked
for.  This error_mark_node gets used as the TYPE_ARG_TYPES, leading to
ICEs in various places that assume this is a TREE_LIST.

This patch checks the result of tsubst_arg_types and propagates the failure
if it returns error_mark_node.  It also adds an assertion to
build_function_type, to fail faster if passed in error_mark_node.

gcc/cp/ChangeLog:
Backport of r267957 from trunk.
2019-01-15  David Malcolm  

PR c++/88795
* pt.c (build_deduction_guide): Bail out if tsubst_arg_types
fails.

gcc/testsuite/ChangeLog:
Backport of r267957 from trunk.
2019-01-15  David Malcolm  

PR c++/88795
* g++.dg/template/pr88795.C: New test.

gcc/ChangeLog:
Backport of r267957 from trunk.
2019-01-15  David Malcolm  

PR c++/88795
* tree.c (build_function_type): Assert that arg_types is not
error_mark_node.


Added:
branches/gcc-8-branch/gcc/testsuite/g++.dg/template/pr88795.C
Modified:
branches/gcc-8-branch/gcc/ChangeLog
branches/gcc-8-branch/gcc/cp/ChangeLog
branches/gcc-8-branch/gcc/cp/pt.c
branches/gcc-8-branch/gcc/testsuite/ChangeLog
branches/gcc-8-branch/gcc/tree.c

[Bug c++/88795] ICE on class-template argument deduction if non-type parameter has indirection

2019-01-15 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88795

--- Comment #5 from David Malcolm  ---
Should be fixed on trunk by r267957.

[Bug c++/88795] ICE on class-template argument deduction if non-type parameter has indirection

2019-01-15 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88795

--- Comment #4 from David Malcolm  ---
Author: dmalcolm
Date: Tue Jan 15 23:29:15 2019
New Revision: 267957

URL: https://gcc.gnu.org/viewcvs?rev=267957=gcc=rev
Log:
Fix ICE on class-template argument deduction (PR c++/88795)

PR c++/88795 reports an ICE building a function_type for a deduction guide
when the substitution into the function signature fails, due to an
error_mark_node being returned from tsubst_arg_types but not being checked
for.  This error_mark_node gets used as the TYPE_ARG_TYPES, leading to
ICEs in various places that assume this is a TREE_LIST.

This patch checks the result of tsubst_arg_types and propagates the failure
if it returns error_mark_node.  It also adds an assertion to
build_function_type, to fail faster if passed in error_mark_node.

gcc/cp/ChangeLog:
PR c++/88795
* pt.c (build_deduction_guide): Bail out if tsubst_arg_types
fails.

gcc/testsuite/ChangeLog:
PR c++/88795
* g++.dg/template/pr88795.C: New test.

gcc/ChangeLog:
PR c++/88795
* tree.c (build_function_type): Assert that arg_types is not
error_mark_node.


Added:
trunk/gcc/testsuite/g++.dg/template/pr88795.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/pt.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree.c

[Bug c++/88795] ICE on class-template argument deduction if non-type parameter has indirection

2019-01-15 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88795

--- Comment #3 from David Malcolm  ---
Candidate patch:
  https://gcc.gnu.org/ml/gcc-patches/2019-01/msg00865.html

[Bug c++/88795] ICE on class-template argument deduction if non-type parameter has indirection

2019-01-15 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88795

David Malcolm  changed:

   What|Removed |Added

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

--- Comment #2 from David Malcolm  ---
ICE occurs at gcc/tree.c:6811 here:

6809case FUNCTION_TYPE:
6810  for (tree t = TYPE_ARG_TYPES (type); t; t = TREE_CHAIN (t))
6811if (TREE_VALUE (t) != error_mark_node)
6812  hstate.add_object (TYPE_HASH (TREE_VALUE (t)));
6813  break;

where "t" itself is error_mark_node, and so the TREE_VALUE (t) is erroneous.

Am working on a fix

[Bug c++/88795] ICE on class-template argument deduction if non-type parameter has indirection

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

Marek Polacek  changed:

   What|Removed |Added

   Keywords||ice-on-valid-code
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-01-10
 CC||mpolacek at gcc dot gnu.org
 Ever confirmed|0   |1

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