public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97034] New: ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*))
@ 2020-09-12 14:51 dimitri.gorokhovik at free dot fr
2020-09-13 22:16 ` [Bug c++/97034] [11 Regression] " mpolacek at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: dimitri.gorokhovik at free dot fr @ 2020-09-12 14:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97034
Bug ID: 97034
Summary: ICE on C++20 code: gcc_assert failure in return type
deduction (gcc/cp/pt.c:26984 in
type_dependent_expression_p(tree_node*))
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: dimitri.gorokhovik at free dot fr
Target Milestone: ---
The code:
#include <tuple>
template <unsigned N>
struct s
{
template <typename R>
struct ss
{
R _1;
unsigned _2;
};
constexpr auto f ()
{
return ss { std::pair <char, int> { 'a', 1 }, 1 };
};
};
when compiled as:
g++ -std=c++20 -o bug-3.o -c bug-3.cpp
produces:
bug-3.cpp: In member function ‘constexpr auto s<N>::f()’:
bug-3.cpp:15:65: internal compiler error: in type_dependent_expression_p, at
cp/pt.c:26984
15 | return ss { std::pair <char, int> { 'a', 1 }, 1 };
| ^
0x680638 type_dependent_expression_p(tree_node*)
../../src/gcc/cp/pt.c:26984
0xa22cf9 maybe_instantiate_noexcept(tree_node*, int)
../../src/gcc/cp/pt.c:25290
0x9598c2 mark_used(tree_node*, int)
../../src/gcc/cp/decl2.c:5552
0xaa8d36 cp_build_addr_expr_1
../../src/gcc/cp/typeck.c:6384
0x8ab692 build_over_call
../../src/gcc/cp/call.c:8522
0x8ae85a build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
../../src/gcc/cp/call.c:4641
0xa1a4ed do_class_deduction
../../src/gcc/cp/pt.c:29027
0xa1a4ed do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
../../src/gcc/cp/pt.c:29085
0xa6def9 finish_compound_literal(tree_node*, tree_node*, int, fcl_t)
../../src/gcc/cp/semantics.c:2934
0x9ca12a cp_parser_functional_cast
../../src/gcc/cp/parser.c:29690
0x9e26d7 cp_parser_postfix_expression
../../src/gcc/cp/parser.c:7251
0x9c443a cp_parser_binary_expression
../../src/gcc/cp/parser.c:9648
0x9c61ce cp_parser_assignment_expression
../../src/gcc/cp/parser.c:9953
0x9c64e2 cp_parser_expression
../../src/gcc/cp/parser.c:10121
0x9d5527 cp_parser_jump_statement
../../src/gcc/cp/parser.c:13192
0x9d5527 cp_parser_statement
../../src/gcc/cp/parser.c:11455
0x9d6a8d cp_parser_statement_seq_opt
../../src/gcc/cp/parser.c:11928
0x9d6b68 cp_parser_compound_statement
../../src/gcc/cp/parser.c:11878
0x9eecb5 cp_parser_function_body
../../src/gcc/cp/parser.c:23177
0x9eecb5 cp_parser_ctor_initializer_opt_and_function_body
../../src/gcc/cp/parser.c:23228
Please submit a full bug report,
GCC version:
g++ (GCC) 11.0.0 20200910 (experimental)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/97034] [11 Regression] ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*))
2020-09-12 14:51 [Bug c++/97034] New: ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*)) dimitri.gorokhovik at free dot fr
@ 2020-09-13 22:16 ` mpolacek at gcc dot gnu.org
2020-09-16 16:27 ` mpolacek at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-13 22:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97034
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Keywords| |ice-on-valid-code
Summary|ICE on C++20 code: |[11 Regression] ICE on
|gcc_assert failure in |C++20 code: gcc_assert
|return type deduction |failure in return type
|(gcc/cp/pt.c:26984 in |deduction
|type_dependent_expression_p |(gcc/cp/pt.c:26984 in
|(tree_node*)) |type_dependent_expression_p
| |(tree_node*))
Last reconfirmed| |2020-09-13
Target Milestone|--- |11.0
CC| |mpolacek at gcc dot gnu.org
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r11-1713.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/97034] [11 Regression] ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*))
2020-09-12 14:51 [Bug c++/97034] New: ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*)) dimitri.gorokhovik at free dot fr
2020-09-13 22:16 ` [Bug c++/97034] [11 Regression] " mpolacek at gcc dot gnu.org
@ 2020-09-16 16:27 ` mpolacek at gcc dot gnu.org
2020-09-16 18:02 ` mpolacek at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-16 16:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97034
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
// PR c++/97034
namespace N {
template <typename, typename> struct S {
template <typename T, typename U> S(T, U);
};
} // namespace N
template <int> struct E {
template <typename T> struct G { T t; };
void fn() { G{N::S<char, int>{'a', 1}}; }
};
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/97034] [11 Regression] ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*))
2020-09-12 14:51 [Bug c++/97034] New: ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*)) dimitri.gorokhovik at free dot fr
2020-09-13 22:16 ` [Bug c++/97034] [11 Regression] " mpolacek at gcc dot gnu.org
2020-09-16 16:27 ` mpolacek at gcc dot gnu.org
@ 2020-09-16 18:02 ` mpolacek at gcc dot gnu.org
2020-09-16 18:42 ` mpolacek at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-16 18:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97034
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The same ICE can be triggered with
template <int>
struct E {
template <typename T>
struct G {
T t;
G(T) { }
};
void fn() { G{1}; }
};
which started with r269093.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/97034] [11 Regression] ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*))
2020-09-12 14:51 [Bug c++/97034] New: ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*)) dimitri.gorokhovik at free dot fr
` (2 preceding siblings ...)
2020-09-16 18:02 ` mpolacek at gcc dot gnu.org
@ 2020-09-16 18:42 ` mpolacek at gcc dot gnu.org
2020-10-12 11:52 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-16 18:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97034
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Another, valid, where C++20 aggregate CTAD should work:
template<typename>
struct E {
template <typename T>
struct G {
T t;
};
void fn() { G{1}; }
};
void
g () {
E<int> e;
e.fn ();
}
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/97034] [11 Regression] ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*))
2020-09-12 14:51 [Bug c++/97034] New: ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*)) dimitri.gorokhovik at free dot fr
` (3 preceding siblings ...)
2020-09-16 18:42 ` mpolacek at gcc dot gnu.org
@ 2020-10-12 11:52 ` rguenth at gcc dot gnu.org
2021-01-09 4:42 ` arthur.j.odwyer at gmail dot com
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-12 11:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97034
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/97034] [11 Regression] ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*))
2020-09-12 14:51 [Bug c++/97034] New: ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*)) dimitri.gorokhovik at free dot fr
` (4 preceding siblings ...)
2020-10-12 11:52 ` rguenth at gcc dot gnu.org
@ 2021-01-09 4:42 ` arthur.j.odwyer at gmail dot com
2021-02-12 1:27 ` mpolacek at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: arthur.j.odwyer at gmail dot com @ 2021-01-09 4:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97034
Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |arthur.j.odwyer at gmail dot com
--- Comment #5 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> ---
Is mine the same bug? Mine is also a regression (trunk crashes where GCC 10.2
had succeeded).
// https://godbolt.org/z/Ysh6as
struct C { void f(auto) noexcept; };
void C::f(auto) noexcept(C::x) {}
Compile with -std=c++20:
<source>:3:29: error: 'x' is not a member of 'C'
3 | void C::f(auto) noexcept(C::x) {}
| ^
<source>:3:6: error: declaration of 'void C::f(auto:2)' has a different
exception specifier
3 | void C::f(auto) noexcept(C::x) {}
| ^
<source>:2:17: note: from previous declaration 'void C::f(auto:1) noexcept'
2 | struct C { void f(auto) noexcept; };
| ^
<source>:3:30: internal compiler error: in type_dependent_expression_p, at
cp/pt.c:27166
3 | void C::f(auto) noexcept(C::x) {}
| ^
0x1cc31d9 internal_error(char const*, ...)
???:0
0x6b25f7 fancy_abort(char const*, int, char const*)
???:0
0x8ee70a type_dependent_expression_p(tree_node*)
???:0
0x137d4f3 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
???:0
0x1381b55 walk_tree_without_duplicates_1(tree_node**, tree_node*
(*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*,
tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false,
default_hash_traits<tree_node*> >*))
???:0
0x8ea937 instantiation_dependent_uneval_expression_p(tree_node*)
???:0
0x8f2198 instantiation_dependent_expression_p(tree_node*)
???:0
0x8f2216 uses_template_parms(tree_node*)
???:0
0x78ffe8 duplicate_decls(tree_node*, tree_node*, bool, bool)
???:0
0x79a2b6 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*,
decl_context, int, tree_node**)
???:0
0x79dda6 start_function(cp_decl_specifier_seq*, cp_declarator const*,
tree_node*)
???:0
0x8d803d c_parse_file()
???:0
0xa54072 c_common_parse_file()
???:0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/97034] [11 Regression] ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*))
2020-09-12 14:51 [Bug c++/97034] New: ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*)) dimitri.gorokhovik at free dot fr
` (5 preceding siblings ...)
2021-01-09 4:42 ` arthur.j.odwyer at gmail dot com
@ 2021-02-12 1:27 ` mpolacek at gcc dot gnu.org
2021-02-12 1:44 ` mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-02-12 1:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97034
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Arthur O'Dwyer from comment #5)
> Is mine the same bug? Mine is also a regression (trunk crashes where GCC
> 10.2 had succeeded).
>
> // https://godbolt.org/z/Ysh6as
> struct C { void f(auto) noexcept; };
> void C::f(auto) noexcept(C::x) {}
>
> Compile with -std=c++20:
>
>
> <source>:3:29: error: 'x' is not a member of 'C'
> 3 | void C::f(auto) noexcept(C::x) {}
> | ^
> <source>:3:6: error: declaration of 'void C::f(auto:2)' has a different
> exception specifier
> 3 | void C::f(auto) noexcept(C::x) {}
> | ^
> <source>:2:17: note: from previous declaration 'void C::f(auto:1) noexcept'
> 2 | struct C { void f(auto) noexcept; };
> | ^
> <source>:3:30: internal compiler error: in type_dependent_expression_p, at
> cp/pt.c:27166
> 3 | void C::f(auto) noexcept(C::x) {}
> | ^
> 0x1cc31d9 internal_error(char const*, ...)
> ???:0
> 0x6b25f7 fancy_abort(char const*, int, char const*)
> ???:0
> 0x8ee70a type_dependent_expression_p(tree_node*)
> ???:0
> 0x137d4f3 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
> void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
> tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
> void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
> ???:0
> 0x1381b55 walk_tree_without_duplicates_1(tree_node**, tree_node*
> (*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*,
> tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false,
> default_hash_traits<tree_node*> >*))
> ???:0
> 0x8ea937 instantiation_dependent_uneval_expression_p(tree_node*)
> ???:0
> 0x8f2198 instantiation_dependent_expression_p(tree_node*)
> ???:0
> 0x8f2216 uses_template_parms(tree_node*)
> ???:0
> 0x78ffe8 duplicate_decls(tree_node*, tree_node*, bool, bool)
> ???:0
> 0x79a2b6 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*,
> decl_context, int, tree_node**)
> ???:0
> 0x79dda6 start_function(cp_decl_specifier_seq*, cp_declarator const*,
> tree_node*)
> ???:0
> 0x8d803d c_parse_file()
> ???:0
> 0xa54072 c_common_parse_file()
> ???:0
I think that is a different problem (the original problem here was with
deduction guides).
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/97034] [11 Regression] ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*))
2020-09-12 14:51 [Bug c++/97034] New: ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*)) dimitri.gorokhovik at free dot fr
` (6 preceding siblings ...)
2021-02-12 1:27 ` mpolacek at gcc dot gnu.org
@ 2021-02-12 1:44 ` mpolacek at gcc dot gnu.org
2021-02-12 4:15 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-02-12 1:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97034
--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Candidate patch:
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -27279,7 +27279,10 @@ type_dependent_expression_p (tree expression)
&& DECL_UNIQUE_FRIEND_P (expression)
&& (!DECL_FRIEND_CONTEXT (expression)
|| dependent_type_p (DECL_FRIEND_CONTEXT (expression))))
- && !DECL_LOCAL_DECL_P (expression))
+ && !DECL_LOCAL_DECL_P (expression)
+ /* We build deduction guides without any DECL_CONTEXT, but they can
+ be type-dependent. */
+ && !deduction_guide_p (expression))
{
gcc_assert (!dependent_type_p (TREE_TYPE (expression))
|| undeduced_auto_decl (expression));
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/97034] [11 Regression] ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*))
2020-09-12 14:51 [Bug c++/97034] New: ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*)) dimitri.gorokhovik at free dot fr
` (7 preceding siblings ...)
2021-02-12 1:44 ` mpolacek at gcc dot gnu.org
@ 2021-02-12 4:15 ` mpolacek at gcc dot gnu.org
2021-03-03 14:53 ` cvs-commit at gcc dot gnu.org
2021-03-03 15:04 ` mpolacek at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-02-12 4:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97034
--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Alternative patch that I'm more happy about:
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -28761,6 +28761,7 @@ build_deduction_guide (tree type, tree ctor, tree
outer_args, tsubst_flags_t com
tree ded_fn = build_lang_decl_loc (loc,
FUNCTION_DECL,
dguide_name (type), fntype);
+ DECL_CONTEXT (ded_fn) = type;
DECL_ARGUMENTS (ded_fn) = fargs;
DECL_ARTIFICIAL (ded_fn) = true;
DECL_NONCONVERTING_P (ded_fn) = explicit_p;
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/97034] [11 Regression] ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*))
2020-09-12 14:51 [Bug c++/97034] New: ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*)) dimitri.gorokhovik at free dot fr
` (8 preceding siblings ...)
2021-02-12 4:15 ` mpolacek at gcc dot gnu.org
@ 2021-03-03 14:53 ` cvs-commit at gcc dot gnu.org
2021-03-03 15:04 ` mpolacek at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-03 14:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97034
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:1dabbfb0f4a9fbdc77e1ea4db7302586f00895e1
commit r11-7483-g1dabbfb0f4a9fbdc77e1ea4db7302586f00895e1
Author: Marek Polacek <polacek@redhat.com>
Date: Fri Feb 12 12:21:15 2021 -0500
c++: ICE with deduction guide in checking type-dep [PR99009, PR97034]
We represent deduction guides with FUNCTION_DECLs, but they are built
without DECL_CONTEXT, leading to an ICE in type_dependent_expression_p
on the assert that the type of a function template with no dependent
(innermost!) template arguments must be non-dependent. Consider the
attached class-deduction79.C: we create a deduction guide:
template<class T> G(T)-> E<Z>::G<T>
we deduce T and create a partial instantiation:
G(T) -> E<Z>::G<T> [with T = int]
And then do_class_deduction wants to create a CALL_EXPR from the above
using build_new_function_call -> build_over_call which calls mark_used
-> maybe_instantiate_noexcept -> type_dependent_expression_p.
There, the innermost template arguments are non-dependent (<int>), but
the fntype is dependent -- the return type is a TYPENAME_TYPE, and
since we have no DECL_CONTEXT, this check holds:
/* Otherwise, if the function decl isn't from a dependent scope, it can't
be
type-dependent. Checking this is important for functions with auto
return
type, which looks like a dependent type. */
if (TREE_CODE (expression) == FUNCTION_DECL
&& !(DECL_CLASS_SCOPE_P (expression)
&& dependent_type_p (DECL_CONTEXT (expression)))
whereupon we ICE.
This patch fixes it by deferring the class deduction until the
enclosing scope is non-dependent. build_deduction_guide and
maybe_aggr_guide
needed a little tweaking to make the deduction work in a member
template.
Co-Authored-By: Jason Merrill <jason@redhat.com>
gcc/cp/ChangeLog:
PR c++/97034
PR c++/99009
* pt.c (build_deduction_guide): Use INNERMOST_TEMPLATE_ARGS.
(maybe_aggr_guide): Use the original template type where needed.
In
a class member template, partially instantiate the result of
collect_ctor_idx_types.
(do_class_deduction): Defer the deduction until the enclosing
scope is non-dependent.
gcc/testsuite/ChangeLog:
PR c++/97034
PR c++/99009
* g++.dg/cpp1z/class-deduction81.C: New test.
* g++.dg/cpp1z/class-deduction82.C: New test.
* g++.dg/cpp2a/class-deduction-aggr8.C: New test.
* g++.dg/cpp2a/class-deduction-aggr9.C: New test.
* g++.dg/cpp2a/class-deduction-aggr10.C: New test.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/97034] [11 Regression] ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*))
2020-09-12 14:51 [Bug c++/97034] New: ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*)) dimitri.gorokhovik at free dot fr
` (9 preceding siblings ...)
2021-03-03 14:53 ` cvs-commit at gcc dot gnu.org
@ 2021-03-03 15:04 ` mpolacek at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-03 15:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97034
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-03-03 15:04 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-12 14:51 [Bug c++/97034] New: ICE on C++20 code: gcc_assert failure in return type deduction (gcc/cp/pt.c:26984 in type_dependent_expression_p(tree_node*)) dimitri.gorokhovik at free dot fr
2020-09-13 22:16 ` [Bug c++/97034] [11 Regression] " mpolacek at gcc dot gnu.org
2020-09-16 16:27 ` mpolacek at gcc dot gnu.org
2020-09-16 18:02 ` mpolacek at gcc dot gnu.org
2020-09-16 18:42 ` mpolacek at gcc dot gnu.org
2020-10-12 11:52 ` rguenth at gcc dot gnu.org
2021-01-09 4:42 ` arthur.j.odwyer at gmail dot com
2021-02-12 1:27 ` mpolacek at gcc dot gnu.org
2021-02-12 1:44 ` mpolacek at gcc dot gnu.org
2021-02-12 4:15 ` mpolacek at gcc dot gnu.org
2021-03-03 14:53 ` cvs-commit at gcc dot gnu.org
2021-03-03 15:04 ` mpolacek 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).