Bug 68828 - [concepts] ICE in fold with requires and function call around parameters
Summary: [concepts] ICE in fold with requires and function call around parameters
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: ---
Assignee: Marek Polacek
URL:
Keywords:
: 68826 68827 (view as bug list)
Depends on:
Blocks: concepts
  Show dependency treegraph
 
Reported: 2015-12-10 06:43 UTC by Jarryd Beck
Modified: 2020-09-17 20:16 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 10.0
Known to fail:
Last reconfirmed: 2020-07-23 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:43:18 UTC
The following causes r231384 to ICE

template <typename... Types>
struct Var
{
};

struct A
{
};

template <typename T>
T
forward(T t)
{
  return static_cast<T>(t);
}

template <typename V, typename... Types, typename... Args>
bool requires_types_args(V&& v, Var<Types...>&, Args&&... args)
{
  return (true && ... &&
    requires (V&& v, Types type, Args... args) {
      foo(forward<V>(v), forward<Types>(type), 
        forward<Args>(args)...);
    }
  );
}

void bar()
{
  Var<int, char> v;
  requires_types_args(A(), v, 1, 'b');
}


Error is:

g++ -std=c++1z fold-ice3.cpp
fold-ice3.cpp: In instantiation of ‘bool requires_types_args(V&&, Var<Types ...>&, Args&& ...) [with V = A; Types = int, char; Args = {int, char}]’:
fold-ice3.cpp:31:37:   required from here
fold-ice3.cpp:22:10: error: ‘foo’ was not declared in this scope
       foo(forward<V>(v), forward<Types>(type),
       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         forward<Args>(args)...);
         ~~~~~~~~~~~~~~~~~~~~~~~

fold-ice3.cpp:22:10: error: ‘foo’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
fold-ice3.cpp:22:10: note: ‘foo’ declared here, later in the translation unit
fold-ice3.cpp:26:1: internal compiler error: tree check: expected tree that contains ‘typed’ structure, have ‘simple_req’ in cp_fold, at cp/cp-gimplify.c:1948
 }
 ^

0xf62e24 tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*)
	../../../src/gcc-git/gcc/tree.c:9771
0x7f610c contains_struct_check(tree_node*, tree_node_structure_enum, char const*, int, char const*)
	../../../src/gcc-git/gcc/tree.h:3111
0x7f610c cp_fold
	../../../src/gcc-git/gcc/cp/cp-gimplify.c:1948
0x7f6620 cp_fold_r
	../../../src/gcc-git/gcc/cp/cp-gimplify.c:941
0xf85d82 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*))
	../../../src/gcc-git/gcc/tree.c:11492
0xf85ecd walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*))
	../../../src/gcc-git/gcc/tree.c:11539
0x79fb18 cp_walk_subtrees(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*)
	../../../src/gcc-git/gcc/cp/tree.c:3895
0xf85df8 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*))
	../../../src/gcc-git/gcc/tree.c:11515
0xf861d6 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*))
	../../../src/gcc-git/gcc/tree.c:11809
0x612eaf finish_function(int)
	../../../src/gcc-git/gcc/cp/decl.c:14589
0x641eaf instantiate_decl(tree_node*, int, bool)
	../../../src/gcc-git/gcc/cp/pt.c:21802
0x687c7b instantiate_pending_templates(int)
	../../../src/gcc-git/gcc/cp/pt.c:21897
0x6c8ef1 c_parse_final_cleanups()
	../../../src/gcc-git/gcc/cp/decl2.c:4579
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 Jonathan Wakely 2019-10-29 09:55:11 UTC
No ICE with current trunk.
Comment 2 Marek Polacek 2020-07-23 17:02:01 UTC
Compiles fine since r278449 which came without a test, so let's add this one.
Comment 3 Marek Polacek 2020-07-23 17:09:58 UTC
*** Bug 68827 has been marked as a duplicate of this bug. ***
Comment 4 Marek Polacek 2020-07-23 17:11:42 UTC
*** Bug 68826 has been marked as a duplicate of this bug. ***
Comment 5 CVS Commits 2020-09-17 20:14:59 UTC
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:4f0aa5b051c0d3e81478bcb495e4e072b2d9827d

commit r11-3268-g4f0aa5b051c0d3e81478bcb495e4e072b2d9827d
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Sep 17 15:31:50 2020 -0400

    c++: Add tests for fixed PRs.
    
    Bugzilla inspection turned up a bunch of old(er) PRs that have been
    fixed.  Let's include them not to regress in the future.
    
    gcc/testsuite/ChangeLog:
    
            PR c++/87530
            PR c++/58156
            PR c++/68828
            PR c++/86002
            PR c++/91525
            PR c++/96223
            PR c++/87032
            PR c++/35098
            * g++.dg/cpp0x/move-return4.C: New test.
            * g++.dg/cpp0x/vt-58156.C: New test.
            * g++.dg/cpp2a/concepts-pr68828.C: New test.
            * g++.dg/cpp2a/concepts-pr86002.C: New test.
            * g++.dg/cpp2a/concepts-pr91525.C: New test.
            * g++.dg/cpp2a/constexpr-indeterminate1.C: New test.
            * g++.dg/cpp2a/desig17.C: New test.
            * g++.dg/ext/attrib62.C: New test.
Comment 6 Marek Polacek 2020-09-17 20:16:54 UTC
Fixed.