public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99874] New: ICE Segmentation fault when declared variable template of template lambda
@ 2021-04-01 18:35 hewillk at gmail dot com
2021-04-01 21:18 ` [Bug c++/99874] [11 Regression] " mpolacek at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: hewillk at gmail dot com @ 2021-04-01 18:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99874
Bug ID: 99874
Summary: ICE Segmentation fault when declared variable template
of template lambda
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
https://godbolt.org/z/4fxhP6jf9
template <int>
auto l = []<int x> requires requires { x; } {};
int main() {
l<0>.template operator()<0>();
}
<source>:2:40: internal compiler error: Segmentation fault
2 | auto l = []<int x> requires requires { x; } {};
| ^
0x1cfca39 internal_error(char const*, ...)
???:0
0x917a92 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x73f042 tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x73f08a constraints_satisfied_p(tree_node*, tree_node*)
???:0
0x954d48 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0x6ded59 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
???:0
0x8e126d c_parse_file()
???:0
0xa60292 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99874] [11 Regression] ICE Segmentation fault when declared variable template of template lambda
2021-04-01 18:35 [Bug c++/99874] New: ICE Segmentation fault when declared variable template of template lambda hewillk at gmail dot com
@ 2021-04-01 21:18 ` mpolacek at gcc dot gnu.org
2021-04-03 17:15 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-04-01 21:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99874
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.0
Priority|P3 |P1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-04-01
CC| |mpolacek at gcc dot gnu.org,
| |ppalka at gcc dot gnu.org
Ever confirmed|0 |1
Summary|ICE Segmentation fault when |[11 Regression] ICE
|declared variable template |Segmentation fault when
|of template lambda |declared variable template
| |of template lambda
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed. G++10:
99874.C:2:45: error: expected ‘(’ before ‘{’ token
2 | auto l = []<int x> requires requires { x; } {};
| ^
| (
ICE started with r11-3261. I suppose it's a P1 then?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99874] [11 Regression] ICE Segmentation fault when declared variable template of template lambda
2021-04-01 18:35 [Bug c++/99874] New: ICE Segmentation fault when declared variable template of template lambda hewillk at gmail dot com
2021-04-01 21:18 ` [Bug c++/99874] [11 Regression] " mpolacek at gcc dot gnu.org
@ 2021-04-03 17:15 ` ppalka at gcc dot gnu.org
2021-04-08 17:11 ` cvs-commit at gcc dot gnu.org
2021-04-08 18:41 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-03 17:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99874
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #1)
> Confirmed. G++10:
>
> 99874.C:2:45: error: expected ‘(’ before ‘{’ token
> 2 | auto l = []<int x> requires requires { x; } {};
> | ^
> | (
>
> ICE started with r11-3261. I suppose it's a P1 then?
Probably -- if we add an empty parameter list to the lambda then G++10 accepts.
Looking into it.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99874] [11 Regression] ICE Segmentation fault when declared variable template of template lambda
2021-04-01 18:35 [Bug c++/99874] New: ICE Segmentation fault when declared variable template of template lambda hewillk at gmail dot com
2021-04-01 21:18 ` [Bug c++/99874] [11 Regression] " mpolacek at gcc dot gnu.org
2021-04-03 17:15 ` ppalka at gcc dot gnu.org
@ 2021-04-08 17:11 ` cvs-commit at gcc dot gnu.org
2021-04-08 18:41 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-08 17:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99874
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:123b3e03c911a43054c1f88f5d3110e1d084dd4e
commit r11-8065-g123b3e03c911a43054c1f88f5d3110e1d084dd4e
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Apr 8 13:07:43 2021 -0400
c++: Don't substitute into constraints on lambdas [PR99874]
We currently substitute through a lambda's constraints whenever we
regenerate it via tsubst_lambda_expr. This is the wrong approach
because it can lead to hard errors due to constraints being evaluated
out of order (as in the testcase concepts-lambda17.C below), and because
it doesn't mesh well with the recently added REQUIRES_EXPR_EXTRA_ARGS
mechanism for delaying substitution into requires-expressions, which is
the cause of this PR.
But in order to avoid substituting through a lambda's constraints during
regeneration, we need to be able to get at all in-scope template
parameters and corresponding template arguments during constraint
checking of a lambda's op(). And this information is not easily
available when we need it, it seems.
To that end, the approach that this patch takes is to add two new fields
to LAMBDA_EXPR (and remove one): LAMBDA_EXPR_REGENERATED_FROM
(replacing LAMBDA_EXPR_INSTANTIATED), and LAMBDA_EXPR_REGENERATING_TARGS.
The former allows us to obtain the complete set of template parameters
that are in-scope for a lambda's op(), and the latter gives us all outer
template arguments that were used to regenerate the lambda (analogous to
the TI_TEMPLATE and TI_ARGS of a TEMPLATE_INFO, respectively).
LAMBDA_EXPR_REGENERATING_TARGS is not strictly necessary -- in an
earlier prototype, I walked LAMBDA_EXPR_EXTRA_SCOPE to build up this set
of outer template arguments on demand, but it seems cleaner to do it this
way. (We'd need to walk LAMBDA_EXPR_EXTRA_SCOPE and not DECL/TYPE_CONTEXT
because the latter skips over variable template scopes.)
This patch also renames the predicate instantiated_lambda_fn_p to
regenerated_lambda_fn_p, for sake of consistency with the rest of the
patch which uses "regenerated" instead of "instantiated".
gcc/cp/ChangeLog:
PR c++/99874
* constraint.cc (get_normalized_constraints_from_decl): Handle
regenerated lambdas.
(satisfy_declaration_constraints): Likewise. Check for
dependent args later.
* cp-tree.h (LAMBDA_EXPR_INSTANTIATED): Replace with ...
(LAMBDA_EXPR_REGENERATED_FROM): ... this.
(LAMBDA_EXPR_REGENERATING_TARGS): New.
(tree_lambda_expr::regenerated_from): New data member.
(tree_lambda_expr::regenerating_targs): New data member.
(add_to_template_args): Declare.
(regenerated_lambda_fn_p): Likewise.
(most_general_lambda): Likewise.
* lambda.c (build_lambda_expr): Set LAMBDA_EXPR_REGENERATED_FROM
and LAMBDA_EXPR_REGENERATING_TARGS.
* pt.c (add_to_template_args): No longer static.
(tsubst_function_decl): Unconditionally propagate constraints on
the substituted function decl.
(instantiated_lambda_fn_p): Rename to ...
(regenerated_lambda_fn_p): ... this. Check
LAMBDA_EXPR_REGENERATED_FROM instead of
LAMBDA_EXPR_INSTANTIATED.
(most_general_lambda): Define.
(enclosing_instantiation_of): Adjust after renaming
instantiated_lambda_fn_p.
(tsubst_lambda_expr): Don't set LAMBDA_EXPR_INSTANTIATED. Set
LAMBDA_EXPR_REGENERATED_FROM and LAMBDA_EXPR_REGENERATING_TARGS.
Don't substitute or set constraints on the regenerated lambda.
gcc/testsuite/ChangeLog:
PR c++/99874
* g++.dg/cpp2a/concepts-lambda16.C: New test.
* g++.dg/cpp2a/concepts-lambda17.C: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99874] [11 Regression] ICE Segmentation fault when declared variable template of template lambda
2021-04-01 18:35 [Bug c++/99874] New: ICE Segmentation fault when declared variable template of template lambda hewillk at gmail dot com
` (2 preceding siblings ...)
2021-04-08 17:11 ` cvs-commit at gcc dot gnu.org
@ 2021-04-08 18:41 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-08 18:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99874
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed, thanks for the bug report.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-04-08 18:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01 18:35 [Bug c++/99874] New: ICE Segmentation fault when declared variable template of template lambda hewillk at gmail dot com
2021-04-01 21:18 ` [Bug c++/99874] [11 Regression] " mpolacek at gcc dot gnu.org
2021-04-03 17:15 ` ppalka at gcc dot gnu.org
2021-04-08 17:11 ` cvs-commit at gcc dot gnu.org
2021-04-08 18:41 ` ppalka at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).