public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94521] New: Infinite loop with decltype of function parameter of type decltype([]{})
@ 2020-04-07 15:57 ppalka at gcc dot gnu.org
2020-04-07 16:00 ` [Bug c++/94521] " mpolacek at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-07 15:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94521
Bug ID: 94521
Summary: Infinite loop with decltype of function parameter of
type decltype([]{})
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ppalka at gcc dot gnu.org
Target Milestone: ---
$ cat testcase.C
template <typename>
void spam(decltype([]{}) *s)
{
static_assert(__is_same(int, decltype(s)));
}
void foo()
{
spam<int>(nullptr);
}
$ g++ -std=c++2a testcase.C
^C
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/94521] Infinite loop with decltype of function parameter of type decltype([]{})
2020-04-07 15:57 [Bug c++/94521] New: Infinite loop with decltype of function parameter of type decltype([]{}) ppalka at gcc dot gnu.org
@ 2020-04-07 16:00 ` mpolacek at gcc dot gnu.org
2020-04-09 17:34 ` ppalka at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-07 16:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94521
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-04-07
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
CC| |mpolacek at gcc dot gnu.org
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed. Looks like it never worked.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/94521] Infinite loop with decltype of function parameter of type decltype([]{})
2020-04-07 15:57 [Bug c++/94521] New: Infinite loop with decltype of function parameter of type decltype([]{}) ppalka at gcc dot gnu.org
2020-04-07 16:00 ` [Bug c++/94521] " mpolacek at gcc dot gnu.org
@ 2020-04-09 17:34 ` ppalka at gcc dot gnu.org
2020-04-13 21:04 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-09 17:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94521
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/94521] Infinite loop with decltype of function parameter of type decltype([]{})
2020-04-07 15:57 [Bug c++/94521] New: Infinite loop with decltype of function parameter of type decltype([]{}) ppalka at gcc dot gnu.org
2020-04-07 16:00 ` [Bug c++/94521] " mpolacek at gcc dot gnu.org
2020-04-09 17:34 ` ppalka at gcc dot gnu.org
@ 2020-04-13 21:04 ` cvs-commit at gcc dot gnu.org
2020-04-13 21:05 ` ppalka at gcc dot gnu.org
2021-02-25 21:45 ` cvs-commit at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-13 21:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94521
--- Comment #2 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:1dcb779916502a44b4ae67d6bf60eb59474bd78c
commit r10-7705-g1dcb779916502a44b4ae67d6bf60eb59474bd78c
Author: Patrick Palka <ppalka@redhat.com>
Date: Mon Apr 13 16:53:41 2020 -0400
c++: Infinite diagnostic loop with decltype([]{}) [PR94521]
We are hitting a recursive loop when printing the signature of a function
containing a decltype([]{}) type. The loop is
dump_function_decl -> dump_substitution
-> dump_template_bindings
-> dump_type
-> dump_aggr_type
-> dump_scope -> dump_function_decl
and we loop because dump_template_bindings wants to print the resolved type
of
decltype([]{}) (i.e. just a lambda type), so it calls dump_aggr_type, which
wants to print the function scope of the lambda type. But the function
scope of
the lambda type is the function which we're in the middle of printing.
This patch breaks the loop by passing TFF_NO_FUNCTION_ARGUMENTS to
dump_function_decl from dump_scope, so that we avoid recursing into
dump_substitution and ultimately looping.
This also means we no longer emit the "[with ...]" clause when printing a
function template scope, and we instead just emit its template argument
list in
a more natural way, e.g. instead of
foo(int, char) [with T=bool]::x
we would now print
foo<bool>::x
which seems like an improvement on its own.
The full signature of the function 'spam' in the below testcase is now
void spam(decltype (<lambda>)*) [with T = int; decltype (<lambda>) =
spam<int>::<lambda()>]
gcc/cp/ChangeLog:
PR c++/94521
* error.c (dump_scope): Pass TFF_NO_FUNCTION_ARGUMENTS to
dump_function_decl when printing a function template instantiation
as a
scope.
gcc/testsuite/ChangeLog:
PR c++/94521
* g++.dg/cpp2a/lambda-uneval12.C: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/94521] Infinite loop with decltype of function parameter of type decltype([]{})
2020-04-07 15:57 [Bug c++/94521] New: Infinite loop with decltype of function parameter of type decltype([]{}) ppalka at gcc dot gnu.org
` (2 preceding siblings ...)
2020-04-13 21:04 ` cvs-commit at gcc dot gnu.org
@ 2020-04-13 21:05 ` ppalka at gcc dot gnu.org
2021-02-25 21:45 ` cvs-commit at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-13 21:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94521
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |10.0
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 10.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/94521] Infinite loop with decltype of function parameter of type decltype([]{})
2020-04-07 15:57 [Bug c++/94521] New: Infinite loop with decltype of function parameter of type decltype([]{}) ppalka at gcc dot gnu.org
` (3 preceding siblings ...)
2020-04-13 21:05 ` ppalka at gcc dot gnu.org
@ 2021-02-25 21:45 ` cvs-commit at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-25 21:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94521
--- Comment #4 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:7fb9a1e929db520fd741e60d84ec1a58581a8299
commit r11-7406-g7fb9a1e929db520fd741e60d84ec1a58581a8299
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Feb 25 16:44:34 2021 -0500
c++: Fix pretty printing the context of local class [PR99213]
My r10-7705 patch for PR94521 made us set TFF_NO_FUNCTION_ARGUMENTS when
pretty printing the function scope of a local class type in order to
eliminate infinite recursion with a function signature that contains
decltype([]{}). But due to the way dump_function_decl works, this
change regressed our pretty printing of local class types whose context
contains a class template specialization, as in the testcase below, in
which we wrongly pretty print the two local types as 'A<T>::f<char>::S1'
and 'B<T>::f<int>::S2'.
This patch makes dump_scope pass TFF_NO_TEMPLATE_BINDINGS instead of
TFF_NO_FUNCTION_ARGUMENTS when pretty printing a function scope. It
appears this is the strictly better flag to use: it avoids the infinite
recursion issue, it restores pretty printing of the function parameter
list, and it stops dump_function_decl from trying to print a function
template specialization in its own weird way.
Summary of pretty printing differences for the below testcase:
r10-7704: A<T>::f() [with U = char; T = int]::S1
B<T>::f() [with T = int]::S2
r10-7705: A<T>::f<char>::S1
B<T>::f<int>::S2
this patch: A<int>::f<char>()::S1
B<int>::f()::S2
gcc/cp/ChangeLog:
PR c++/99213
PR c++/94521
* error.c (dump_scope): Pass TFF_NO_TEMPLATE_BINDINGS instead of
TFF_NO_FUNCTION_ARGUMENTS when dumping a function scope.
gcc/testsuite/ChangeLog:
PR c++/99213
PR c++/94521
* g++.dg/diagnostic/local1.C: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-02-25 21:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 15:57 [Bug c++/94521] New: Infinite loop with decltype of function parameter of type decltype([]{}) ppalka at gcc dot gnu.org
2020-04-07 16:00 ` [Bug c++/94521] " mpolacek at gcc dot gnu.org
2020-04-09 17:34 ` ppalka at gcc dot gnu.org
2020-04-13 21:04 ` cvs-commit at gcc dot gnu.org
2020-04-13 21:05 ` ppalka at gcc dot gnu.org
2021-02-25 21:45 ` cvs-commit 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).