public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99850] New: [P1102R2] reject valid lambda syntax in C++23
@ 2021-03-31 16:39 hewillk at gmail dot com
2021-03-31 16:50 ` [Bug c++/99850] " mpolacek at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: hewillk at gmail dot com @ 2021-03-31 16:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99850
Bug ID: 99850
Summary: [P1102R2] reject valid lambda syntax in C++23
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/x5E5cGPTb
auto l = []<auto> requires true -> void {};
gcc incorrectly rejects this valid lambda, you can see more details in
https://stackoverflow.com/questions/66833334/the-validity-of-lambda-expression-with-omitted-parameter-list-in-c23
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99850] [P1102R2] reject valid lambda syntax in C++23
2021-03-31 16:39 [Bug c++/99850] New: [P1102R2] reject valid lambda syntax in C++23 hewillk at gmail dot com
@ 2021-03-31 16:50 ` mpolacek at gcc dot gnu.org
2021-03-31 18:01 ` mpolacek at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-31 16:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99850
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
Last reconfirmed| |2021-03-31
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Keywords| |rejects-valid
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed. I could take a look, unless Jakub wants it.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99850] [P1102R2] reject valid lambda syntax in C++23
2021-03-31 16:39 [Bug c++/99850] New: [P1102R2] reject valid lambda syntax in C++23 hewillk at gmail dot com
2021-03-31 16:50 ` [Bug c++/99850] " mpolacek at gcc dot gnu.org
@ 2021-03-31 18:01 ` mpolacek at gcc dot gnu.org
2021-03-31 19:43 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-31 18:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99850
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99850] [P1102R2] reject valid lambda syntax in C++23
2021-03-31 16:39 [Bug c++/99850] New: [P1102R2] reject valid lambda syntax in C++23 hewillk at gmail dot com
2021-03-31 16:50 ` [Bug c++/99850] " mpolacek at gcc dot gnu.org
2021-03-31 18:01 ` mpolacek at gcc dot gnu.org
@ 2021-03-31 19:43 ` jakub at gcc dot gnu.org
2021-03-31 19:54 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-03-31 19:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99850
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Are you sure it is incorrectly rejected?
http://eel.is/c++draft/expr.prim.lambda.general
says:
lambda-declarator:
lambda-specifiers
( parameter-declaration-clause ) lambda-specifiers requires-clause[opt]
So in my reading, if requires-clause is present, the ()s are not optional.
Otherwise requires-clause[opt] would need to be in the lambda-specifiers
non-terminal or present also after the first lambda-specifiers.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99850] [P1102R2] reject valid lambda syntax in C++23
2021-03-31 16:39 [Bug c++/99850] New: [P1102R2] reject valid lambda syntax in C++23 hewillk at gmail dot com
` (2 preceding siblings ...)
2021-03-31 19:43 ` jakub at gcc dot gnu.org
@ 2021-03-31 19:54 ` jakub at gcc dot gnu.org
2021-04-01 6:58 ` hewillk at gmail dot com
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-03-31 19:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99850
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ah, but in lambda-expression: non-terminal there is another
requires-clause[opt] after the < template-parameter-list >.
So we need to handle
auto l = []<class T> requires true (T t, int n) { };
But during parsing we have parsing of requires clause at that spot after >,
and when ()s are omitted, there is code to handle -> at that spot.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99850] [P1102R2] reject valid lambda syntax in C++23
2021-03-31 16:39 [Bug c++/99850] New: [P1102R2] reject valid lambda syntax in C++23 hewillk at gmail dot com
` (3 preceding siblings ...)
2021-03-31 19:54 ` jakub at gcc dot gnu.org
@ 2021-04-01 6:58 ` hewillk at gmail dot com
2021-04-14 13:03 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: hewillk at gmail dot com @ 2021-04-01 6:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99850
--- Comment #4 from 康桓瑋 <hewillk at gmail dot com> ---
This ICE may be caused by not handle this form.
template <typename...> concept C = true;
auto l = []<typename... Ts> requires (C<Ts> && ...) -> void {};
https://godbolt.org/z/vo8xPd4hY
<source>:3:48: internal compiler error: Segmentation fault
3 | auto l = []<typename... Ts> requires (C<Ts> && ...) -> void {};
| ^~~
0x1cfca39 internal_error(char const*, ...)
???:0
0x940286 convert_generic_types_to_packs(tree_node*, int, 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] 9+ messages in thread
* [Bug c++/99850] [P1102R2] reject valid lambda syntax in C++23
2021-03-31 16:39 [Bug c++/99850] New: [P1102R2] reject valid lambda syntax in C++23 hewillk at gmail dot com
` (4 preceding siblings ...)
2021-04-01 6:58 ` hewillk at gmail dot com
@ 2021-04-14 13:03 ` jakub at gcc dot gnu.org
2021-04-16 7:35 ` cvs-commit at gcc dot gnu.org
2021-04-16 7:36 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-14 13:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99850
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 50592
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50592&action=edit
gcc11-pr99850.patch
Untested fix.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99850] [P1102R2] reject valid lambda syntax in C++23
2021-03-31 16:39 [Bug c++/99850] New: [P1102R2] reject valid lambda syntax in C++23 hewillk at gmail dot com
` (5 preceding siblings ...)
2021-04-14 13:03 ` jakub at gcc dot gnu.org
@ 2021-04-16 7:35 ` cvs-commit at gcc dot gnu.org
2021-04-16 7:36 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-16 7:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99850
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:784de5292c34e287c848b382b431599b818ea76e
commit r11-8210-g784de5292c34e287c848b382b431599b818ea76e
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Apr 16 09:34:26 2021 +0200
c++: Fix up C++23 [] <...> requires primary -> type {} parsing [PR99850]
The requires clause parsing has code to suggest users wrapping
non-primary expressions in (), so if it e.g. parses a primary expression
and sees it is followed by ++, --, ., ( or -> among other things it
will try to reparse it as assignment expression or what and if that works
suggests wrapping it inside of parens.
When it is requires-clause that is after <typename T> etc. it already
has an exception from that as ( can occur in valid C++20 expression there
- starting the parameters of the lambda.
In C++23 another case can occur, as the parameters with the ()s can be
omitted, requires C can be followed immediately by -> which starts a
trailing return type. Even in that case, we don't want to parse that
as C->...
2021-04-16 Jakub Jelinek <jakub@redhat.com>
PR c++/99850
* parser.c (cp_parser_constraint_requires_parens) <case CPP_DEREF>:
If lambda_p, return pce_ok instead of pce_maybe_postfix.
* g++.dg/cpp23/lambda-specifiers2.C: New test.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99850] [P1102R2] reject valid lambda syntax in C++23
2021-03-31 16:39 [Bug c++/99850] New: [P1102R2] reject valid lambda syntax in C++23 hewillk at gmail dot com
` (6 preceding siblings ...)
2021-04-16 7:35 ` cvs-commit at gcc dot gnu.org
@ 2021-04-16 7:36 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-16 7:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99850
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Assignee|mpolacek at gcc dot gnu.org |jakub at gcc dot gnu.org
Status|ASSIGNED |RESOLVED
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-04-16 7:36 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 16:39 [Bug c++/99850] New: [P1102R2] reject valid lambda syntax in C++23 hewillk at gmail dot com
2021-03-31 16:50 ` [Bug c++/99850] " mpolacek at gcc dot gnu.org
2021-03-31 18:01 ` mpolacek at gcc dot gnu.org
2021-03-31 19:43 ` jakub at gcc dot gnu.org
2021-03-31 19:54 ` jakub at gcc dot gnu.org
2021-04-01 6:58 ` hewillk at gmail dot com
2021-04-14 13:03 ` jakub at gcc dot gnu.org
2021-04-16 7:35 ` cvs-commit at gcc dot gnu.org
2021-04-16 7:36 ` jakub 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).