Bug 83287 - [8 Regression] ice in tsubst_copy, at cp/pt.c:14884
Summary: [8 Regression] ice in tsubst_copy, at cp/pt.c:14884
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: 8.0
Assignee: Nathan Sidwell
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2017-12-05 09:57 UTC by David Binderman
Modified: 2018-01-17 18:16 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 7.2.1
Known to fail:
Last reconfirmed: 2017-12-05 00:00:00


Attachments
gzipped C++ source code (257.39 KB, application/gzip)
2017-12-05 09:57 UTC, David Binderman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2017-12-05 09:57:16 UTC
Created attachment 42793 [details]
gzipped C++ source code

The attached C++ source code, with recent gcc trunk, does this:

In file included from array_real.cpp:28:
array_tlp.hpp: In instantiation of ‘void ArrayOperatorF() [with K = double; KK =
 double]’:
array_real.cpp:45:35:   required from here
array_tlp.hpp:1760:27: internal compiler error: in tsubst_copy, at cp/pt.c:14884
0x7e5bf2 tsubst_copy
	../../trunk/gcc/cp/pt.c:14884
0x7cc740 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bo
ol)
	../../trunk/gcc/cp/pt.c:18294
0x7cf287 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bo
ol)
	../../trunk/gcc/cp/pt.c:17929
0x7cc588 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bo
ol)
	../../trunk/gcc/cp/pt.c:17438
0x7cd121 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bo
ol)

This bug seems to have been around since before revision 248835.

Here is a reduced piece of code which seems to demonstrate the problem:

void a();
namespace {
void a();
}
template <class, class> b() { a }
void c {
  b<double, double>()
}
Comment 1 Richard Biener 2017-12-05 10:44:51 UTC
Confirmed.
Comment 2 Jakub Jelinek 2017-12-05 11:43:25 UTC
Started with r248250.  Slightly cleaned up testcase:

void foo ();
namespace {
void foo ();
}
template <class, class>
void
bar ()
{
  void *p = (void *) foo;
}

void
baz ()
{
  bar<double, double> ();
}
Comment 3 Nathan Sidwell 2017-12-05 17:30:29 UTC
Author: nathan
Date: Tue Dec  5 17:29:58 2017
New Revision: 255429

URL: https://gcc.gnu.org/viewcvs?rev=255429&root=gcc&view=rev
Log:
[PR C++/83287] Mark lookup for keeping

https://gcc.gnu.org/ml/gcc-patches/2017-12/msg00242.html
	PR c++/83287
	* tree.c (build_min): Check CAST_EXPR arg for OVERLOADs.

	* g++.dg/lookup/pr83287.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/lookup/pr83287.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/tree.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Nathan Sidwell 2017-12-05 17:43:30 UTC
Fixed 255429.
Comment 5 David Binderman 2018-01-16 17:17:57 UTC
I am still seeing the original unreduced code going wrong:

In file included from array_real.cpp:28:
array_tlp.hpp: In instantiation of ‘void ArrayOperatorF() [with K = double; KK =
 double]’:
array_real.cpp:45:35:   required from here
array_tlp.hpp:1760:27: internal compiler error: in tsubst_copy, at cp/pt.c:14881

with revision 256722. The reduced code seems to work fine.

Time for a deeper look ?
Comment 6 Jakub Jelinek 2018-01-17 10:26:56 UTC
Reduced testcase that still ICEs, starting with the same revision:

void foo ();
namespace {
void foo ();
}

template <class, class T>
void
bar ()
{
  new T (foo);
}

void
baz ()
{
  bar <double, double> ();
}
Comment 7 Nathan Sidwell 2018-01-17 18:12:20 UTC
Author: nathan
Date: Wed Jan 17 18:11:49 2018
New Revision: 256809

URL: https://gcc.gnu.org/viewcvs?rev=256809&root=gcc&view=rev
Log:
[C++/83287] Another overload lookup ice

https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01580.html
	PR c++/83287
	* init.c (build_raw_new_expr): Scan list for lookups to keep.

	PR c++/83287
	* g++.dg/lookup/pr83287-2.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/lookup/pr83287-2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/init.c
    trunk/gcc/testsuite/ChangeLog
Comment 8 Nathan Sidwell 2018-01-17 18:16:48 UTC
Resolved r256809.  Manually tested original testcase this time too.