Bug 68826 - [concepts] ICE in fold expression with requires
Summary: [concepts] ICE in fold expression with requires
Status: RESOLVED DUPLICATE of bug 68828
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: concepts
  Show dependency treegraph
 
Reported: 2015-12-10 06:29 UTC by Jarryd Beck
Modified: 2020-07-23 17:11 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 6.3.0, 7.0
Last reconfirmed: 2017-03-17 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jarryd Beck 2015-12-10 06:29:15 UTC
r231384

ICE in the fold expression in the following code:

template <typename... Types>
bool requires_types(Types&&... types)
{
  return (true && ... &&
    requires { foo(types); });
}

void bar()
{
  requires_types('c', 1, "hi");
}


The error is:

g++ -std=c++1z fold-ice1.cpp -c
fold-ice1.cpp: In instantiation of ‘bool requires_types(Types&& ...) [with Types = {char, int, const char (&)[3]}]’:
fold-ice1.cpp:10:30:   required from here
fold-ice1.cpp:5:19: internal compiler error: in tsubst_copy, at cp/pt.c:13729
     requires { foo(types); });
                ~~~^~~~~~~

0x64d155 tsubst_copy
	../../../src/gcc-git/gcc/cp/pt.c:13729
0x64e560 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../../src/gcc-git/gcc/cp/pt.c:16822
0x650303 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../../src/gcc-git/gcc/cp/pt.c:16312
0x6451ac tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../../src/gcc-git/gcc/cp/pt.c:15628
0x82133c tsubst_simple_requirement
	../../../src/gcc-git/gcc/cp/constraint.cc:1580
0x82133c tsubst_requirement
	../../../src/gcc-git/gcc/cp/constraint.cc:1636
0x82133c tsubst_requirement_body
	../../../src/gcc-git/gcc/cp/constraint.cc:1659
0x82133c tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
	../../../src/gcc-git/gcc/cp/constraint.cc:1690
0x64f690 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../../src/gcc-git/gcc/cp/pt.c:16980
0x6451ac tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../../src/gcc-git/gcc/cp/pt.c:15628
0x66176b gen_elem_of_pack_expansion_instantiation
	../../../src/gcc-git/gcc/cp/pt.c:10514
0x66176b tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*)
	../../../src/gcc-git/gcc/cp/pt.c:10944
0x64b69c tsubst_fold_expr_pack
	../../../src/gcc-git/gcc/cp/pt.c:10604
0x64b69c tsubst_binary_left_fold
	../../../src/gcc-git/gcc/cp/pt.c:10661
0x64b69c tsubst_copy
	../../../src/gcc-git/gcc/cp/pt.c:14303
0x650248 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../../src/gcc-git/gcc/cp/pt.c:16058
0x6451ac tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../../src/gcc-git/gcc/cp/pt.c:15628
0x644457 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../../src/gcc-git/gcc/cp/pt.c:14940
0x644f9b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../../src/gcc-git/gcc/cp/pt.c:15116
0x641e06 instantiate_decl(tree_node*, int, bool)
	../../../src/gcc-git/gcc/cp/pt.c:21780
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Martin Sebor 2017-03-17 23:02:34 UTC
Confirmed with today's top of trunk (GCC 7.0).  Same stack trace.
Comment 2 Jonathan Wakely 2019-10-15 08:41:26 UTC
No ICE with current trunk:

68826.cc: In instantiation of 'bool requires_types(Types&& ...) [with Types = {char, int, const char (&)[3]}]':
68826.cc:10:30:   required from here
68826.cc:5:19: error: 'foo' was not declared in this scope
    5 |     requires { foo(types); });
      |                ~~~^~~~~~~
68826.cc:5:19: error: 'foo' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
68826.cc:5:19: error: 'foo' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
Comment 3 Marek Polacek 2020-07-23 17:11:42 UTC
Also compiles fine since r278449.

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