public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/112769] New: ICE on valid code related to requires-expression
@ 2023-11-29 19:25 janpmoeller at gmx dot de
2023-11-30 18:48 ` [Bug c++/112769] " janpmoeller at gmx dot de
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: janpmoeller at gmx dot de @ 2023-11-29 19:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112769
Bug ID: 112769
Summary: ICE on valid code related to requires-expression
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: janpmoeller at gmx dot de
Target Milestone: ---
All gcc versions since (and including) 11.2 reject the following valid C++20
code:
//////////////////////////////////////////////////////////////
template<int I, typename T>
struct type
{
constexpr explicit type(T value)
{
}
template<typename U>
constexpr explicit type(type<I, U> value)
requires requires { T{value}; }
{
}
};
template <typename T>
using alias = type<0, T>;
constexpr alias foo{123};
//////////////////////////////////////////////////////////////
The reported error is:
##############################################################
<source>:11:18: internal compiler error: in add_outermost_template_args, at
cp/pt.cc:617
11 | requires requires { T{value}; }
| ^~~~~~~~~~~~~~~~~~~~~~
0x1ce7bde internal_error(char const*, ...)
???:0
0x7290fc fancy_abort(char const*, int, char const*)
???:0
0x7879b6 tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x783c90 tsubst_constraint(tree_node*, tree_node*, int, tree_node*)
???:0
0x783df1 tsubst_constraint_info(tree_node*, tree_node*, int, tree_node*)
???:0
0x8b1e90 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int, tree_node*)
???:0
0x7ccd01 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
???:0
0x89fd5b c_parse_file()
???:0
0x98c5d9 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Preprocessed source stored into /tmp/cclpGAjI.out file, please attach this to
your bugreport.
Compiler returned: 1
##############################################################
gcc-11.1 accepts the code.Here is a link to compiler explorer with the same
example: https://godbolt.org/z/aq1d53anv
Note that the first (non-template) constructor is required to make the code
valid, but it is not required to reproduce the issue. Removing it still leads
to the same ICE on gcc > 11.1, whereas gcc-11.1 (correctly) rejects it due to
failed argument deduction.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/112769] ICE on valid code related to requires-expression
2023-11-29 19:25 [Bug c++/112769] New: ICE on valid code related to requires-expression janpmoeller at gmx dot de
@ 2023-11-30 18:48 ` janpmoeller at gmx dot de
2024-02-02 17:57 ` [Bug c++/112769] [11/12/13/14 Regression] " ppalka at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: janpmoeller at gmx dot de @ 2023-11-30 18:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112769
--- Comment #1 from janpmoeller at gmx dot de ---
The following equivalent program does not trigger the ICE:
//////////////////////////////////////////////////////////////
template<typename T, typename U>
concept C = requires (U u) { T{u}; };
template<int I, typename T>
struct type
{
constexpr explicit type(T value)
{
}
template<typename U>
constexpr explicit type(type<I, U> value)
requires C<T, type<I, U>>
{
}
};
template <typename T>
using alias = type<0, T>;
constexpr alias foo{123};
//////////////////////////////////////////////////////////////
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/112769] [11/12/13/14 Regression] ICE on valid code related to requires-expression
2023-11-29 19:25 [Bug c++/112769] New: ICE on valid code related to requires-expression janpmoeller at gmx dot de
2023-11-30 18:48 ` [Bug c++/112769] " janpmoeller at gmx dot de
@ 2024-02-02 17:57 ` ppalka at gcc dot gnu.org
2024-02-02 17:59 ` ppalka at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-02-02 17:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112769
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
CC| |ppalka at gcc dot gnu.org
Summary|ICE on valid code related |[11/12/13/14 Regression]
|to requires-expression |ICE on valid code related
| |to requires-expression
Ever confirmed|0 |1
Last reconfirmed| |2024-02-02
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=101181
Target Milestone|--- |11.5
Known to work| |11.1.0
Known to fail| |11.4.0, 12.3.0, 13.2.0,
| |14.0
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, we started ICEing with a non-checking compiler after r12-2222 /
r11-8734.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/112769] [11/12/13/14 Regression] ICE on valid code related to requires-expression
2023-11-29 19:25 [Bug c++/112769] New: ICE on valid code related to requires-expression janpmoeller at gmx dot de
2023-11-30 18:48 ` [Bug c++/112769] " janpmoeller at gmx dot de
2024-02-02 17:57 ` [Bug c++/112769] [11/12/13/14 Regression] " ppalka at gcc dot gnu.org
@ 2024-02-02 17:59 ` ppalka at gcc dot gnu.org
2024-02-03 0:07 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-02-02 17:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112769
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also|https://gcc.gnu.org/bugzill |
|a/show_bug.cgi?id=111222 |
CC| |stevenxia990430 at gmail dot com
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 111222 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/112769] [11/12/13/14 Regression] ICE on valid code related to requires-expression
2023-11-29 19:25 [Bug c++/112769] New: ICE on valid code related to requires-expression janpmoeller at gmx dot de
` (2 preceding siblings ...)
2024-02-02 17:59 ` ppalka at gcc dot gnu.org
@ 2024-02-03 0:07 ` cvs-commit at gcc dot gnu.org
2024-02-03 0:11 ` [Bug c++/112769] [11/12/13 " ppalka at gcc dot gnu.org
2024-04-15 15:34 ` [Bug c++/112769] [11/12 " ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-03 0:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112769
--- Comment #4 from GCC 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:686b5eb9c9ee623a604dde5c49fa11c23f384c62
commit r14-8770-g686b5eb9c9ee623a604dde5c49fa11c23f384c62
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri Feb 2 19:07:08 2024 -0500
c++: requires-exprs and partial constraint subst [PR110006]
In r11-3261-gb28b621ac67bee we made tsubst_requires_expr never partially
substitute into a requires-expression so as to avoid checking its
requirements out of order during e.g. generic lambda regeneration.
These PRs however illustrate that we still sometimes do need to
partially substitute into a requires-expression, in particular when it
appears in associated constraints that we're directly substituting for
sake of declaration matching or dguide constraint rewriting. In these
cases we're being called from tsubst_constraint during which
processing_constraint_expression_p is true, so this patch checks this
predicate to control whether we defer substitution or partially
substitute.
In turn, we now need to propagate semantic tsubst flags through
tsubst_requires_expr rather than just using tf_none, notably for sake of
dguide constraint rewriting which sets tf_dguide.
PR c++/110006
PR c++/112769
gcc/cp/ChangeLog:
* constraint.cc (subst_info::quiet): Accomodate non-diagnostic
tsubst flags.
(tsubst_valid_expression_requirement): Likewise.
(tsubst_simple_requirement): Return a substituted _REQ node when
processing_template_decl.
(tsubst_type_requirement_1): Accomodate non-diagnostic tsubst
flags.
(tsubst_type_requirement): Return a substituted _REQ node when
processing_template_decl.
(tsubst_compound_requirement): Likewise. Accomodate non-diagnostic
tsubst flags.
(tsubst_nested_requirement): Likewise.
(tsubst_requires_expr): Don't defer partial substitution when
processing_constraint_expression_p is true, in which case return
a substituted REQUIRES_EXPR.
* pt.cc (tsubst_expr) <case REQUIRES_EXPR>: Accomodate
non-diagnostic tsubst flags.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/class-deduction-alias18.C: New test.
* g++.dg/cpp2a/concepts-friend16.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/112769] [11/12/13 Regression] ICE on valid code related to requires-expression
2023-11-29 19:25 [Bug c++/112769] New: ICE on valid code related to requires-expression janpmoeller at gmx dot de
` (3 preceding siblings ...)
2024-02-03 0:07 ` cvs-commit at gcc dot gnu.org
@ 2024-02-03 0:11 ` ppalka at gcc dot gnu.org
2024-04-15 15:34 ` [Bug c++/112769] [11/12 " ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-02-03 0:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112769
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[11/12/13/14 Regression] |[11/12/13 Regression] ICE
|ICE on valid code related |on valid code related to
|to requires-expression |requires-expression
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 14 so far.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/112769] [11/12 Regression] ICE on valid code related to requires-expression
2023-11-29 19:25 [Bug c++/112769] New: ICE on valid code related to requires-expression janpmoeller at gmx dot de
` (4 preceding siblings ...)
2024-02-03 0:11 ` [Bug c++/112769] [11/12/13 " ppalka at gcc dot gnu.org
@ 2024-04-15 15:34 ` ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-15 15:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112769
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[11/12/13 Regression] ICE |[11/12 Regression] ICE on
|on valid code related to |valid code related to
|requires-expression |requires-expression
--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Now also backported for GCC 13.3 as r13-8608-g38c2679ff9330d and
r13-8609-g265f207a46bc38.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-04-15 15:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-29 19:25 [Bug c++/112769] New: ICE on valid code related to requires-expression janpmoeller at gmx dot de
2023-11-30 18:48 ` [Bug c++/112769] " janpmoeller at gmx dot de
2024-02-02 17:57 ` [Bug c++/112769] [11/12/13/14 Regression] " ppalka at gcc dot gnu.org
2024-02-02 17:59 ` ppalka at gcc dot gnu.org
2024-02-03 0:07 ` cvs-commit at gcc dot gnu.org
2024-02-03 0:11 ` [Bug c++/112769] [11/12/13 " ppalka at gcc dot gnu.org
2024-04-15 15:34 ` [Bug c++/112769] [11/12 " 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).