public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99546] New: Weird return value of C++20 requires expression
@ 2021-03-11 8:49 hewillk at gmail dot com
2021-03-11 8:57 ` [Bug c++/99546] " hewillk at gmail dot com
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: hewillk at gmail dot com @ 2021-03-11 8:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99546
Bug ID: 99546
Summary: Weird return value of C++20 requires expression
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: ---
gcc-trunk accepts following code:
int main() {
constexpr auto b = requires { []{}; };
static_assert(b);
static_assert(!b);
}
(godbolt: https://godbolt.org/z/4K5vq8)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99546] Weird return value of C++20 requires expression
2021-03-11 8:49 [Bug c++/99546] New: Weird return value of C++20 requires expression hewillk at gmail dot com
@ 2021-03-11 8:57 ` hewillk at gmail dot com
2021-03-11 13:35 ` redi at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: hewillk at gmail dot com @ 2021-03-11 8:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99546
--- Comment #1 from 康桓瑋 <hewillk at gmail dot com> ---
You can see more weird cases in this:
https://stackoverflow.com/questions/66578966/weird-return-value-of-c20-requires-expression.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99546] Weird return value of C++20 requires expression
2021-03-11 8:49 [Bug c++/99546] New: Weird return value of C++20 requires expression hewillk at gmail dot com
2021-03-11 8:57 ` [Bug c++/99546] " hewillk at gmail dot com
@ 2021-03-11 13:35 ` redi at gcc dot gnu.org
2021-03-11 15:30 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2021-03-11 13:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99546
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Keywords|wrong-code |accepts-invalid
Ever confirmed|0 |1
Last reconfirmed| |2021-03-11
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think the requires expression should be rejected as ill-formed.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99546] Weird return value of C++20 requires expression
2021-03-11 8:49 [Bug c++/99546] New: Weird return value of C++20 requires expression hewillk at gmail dot com
2021-03-11 8:57 ` [Bug c++/99546] " hewillk at gmail dot com
2021-03-11 13:35 ` redi at gcc dot gnu.org
@ 2021-03-11 15:30 ` redi at gcc dot gnu.org
2021-03-20 8:35 ` hewillk at gmail dot com
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2021-03-11 15:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99546
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|accepts-invalid |wrong-code
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
My mistake, the requires-expression is valid, so it is just a wrong-code big as
you originally said.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99546] Weird return value of C++20 requires expression
2021-03-11 8:49 [Bug c++/99546] New: Weird return value of C++20 requires expression hewillk at gmail dot com
` (2 preceding siblings ...)
2021-03-11 15:30 ` redi at gcc dot gnu.org
@ 2021-03-20 8:35 ` hewillk at gmail dot com
2022-09-20 10:09 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: hewillk at gmail dot com @ 2021-03-20 8:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99546
--- Comment #4 from 康桓瑋 <hewillk at gmail dot com> ---
same form, but this will trigger ICE:
====
struct S{
constexpr static auto s = requires { []; };
};
====
<source>:1:8: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in override_type_for_decl_p, at dwarf2out.c:23786
1 | struct S{
| ^
0x1cfa229 internal_error(char const*, ...)
???:0
0x67b5e5 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
???:0
0xf3666f rest_of_type_compilation(tree_node*, int)
???:0
0x70c969 finish_struct_1(tree_node*)
???:0
0x70e754 finish_struct(tree_node*, tree_node*)
???:0
0x8e121d c_parse_file()
???:0
0xa5f812 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99546] Weird return value of C++20 requires expression
2021-03-11 8:49 [Bug c++/99546] New: Weird return value of C++20 requires expression hewillk at gmail dot com
` (3 preceding siblings ...)
2021-03-20 8:35 ` hewillk at gmail dot com
@ 2022-09-20 10:09 ` redi at gcc dot gnu.org
2022-09-20 10:15 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-20 10:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99546
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to 康桓瑋 from comment #4)
> same form, but this will trigger ICE:
That's a completely different bug. I've opened PR 106976
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99546] Weird return value of C++20 requires expression
2021-03-11 8:49 [Bug c++/99546] New: Weird return value of C++20 requires expression hewillk at gmail dot com
` (4 preceding siblings ...)
2022-09-20 10:09 ` redi at gcc dot gnu.org
@ 2022-09-20 10:15 ` redi at gcc dot gnu.org
2024-02-15 13:58 ` gieseanw+gcc at gmail dot com
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-20 10:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99546
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2021-08-16 00:00:00 |2022-9-20
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to 康桓瑋 from comment #1)
> You can see more weird cases in this:
> https://stackoverflow.com/questions/66578966/weird-return-value-of-c20-
> requires-expression.
Copying that here instead of linking to impermanent SO comments:
template <bool b>
void foo() {
static_assert(b);
}
int main() {
constexpr bool b = requires { []{}; };
foo<!b>();
foo<b>();
}
The bool appears to not be a constant expression:
x.C: In function 'int main()':
x.C:8:10: error: no matching function for call to 'foo<(!(bool)b)>()'
8 | foo<!b>();
| ~~~~~~~^~
x.C:2:6: note: candidate: 'template<bool b> void foo()'
2 | void foo() {
| ^~~
x.C:2:6: note: template argument deduction/substitution failed:
x.C:9:9: error: no matching function for call to 'foo<b>()'
9 | foo<b>();
| ~~~~~~^~
x.C:2:6: note: candidate: 'template<bool b> void foo()'
2 | void foo() {
| ^~~
x.C:2:6: note: template argument deduction/substitution failed:
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99546] Weird return value of C++20 requires expression
2021-03-11 8:49 [Bug c++/99546] New: Weird return value of C++20 requires expression hewillk at gmail dot com
` (5 preceding siblings ...)
2022-09-20 10:15 ` redi at gcc dot gnu.org
@ 2024-02-15 13:58 ` gieseanw+gcc at gmail dot com
2024-02-15 14:09 ` redi at gcc dot gnu.org
2024-02-15 14:54 ` gieseanw+gcc at gmail dot com
8 siblings, 0 replies; 10+ messages in thread
From: gieseanw+gcc at gmail dot com @ 2024-02-15 13:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99546
Andrew Giese <gieseanw+gcc at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gieseanw+gcc at gmail dot com
--- Comment #7 from Andrew Giese <gieseanw+gcc at gmail dot com> ---
This bug in the OP appears to have been fixed as early as gcc 11.1.
For reference, I'm referring to the following code:
int main() {
constexpr auto b = requires { []{}; };
static_assert(b);
static_assert(!b);
}
https://godbolt.org/z/WzzGMxcz6
Note that the code listed in Jonathan's comment above still fails in 14.0.1
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99546#c6)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99546] Weird return value of C++20 requires expression
2021-03-11 8:49 [Bug c++/99546] New: Weird return value of C++20 requires expression hewillk at gmail dot com
` (6 preceding siblings ...)
2024-02-15 13:58 ` gieseanw+gcc at gmail dot com
@ 2024-02-15 14:09 ` redi at gcc dot gnu.org
2024-02-15 14:54 ` gieseanw+gcc at gmail dot com
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-15 14:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99546
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2022-09-20 00:00:00 |2024-2-15
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The OP's example is supposed to be ill-formed though, it shouldn't compile
successfully. So I don't think it's fixed.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99546] Weird return value of C++20 requires expression
2021-03-11 8:49 [Bug c++/99546] New: Weird return value of C++20 requires expression hewillk at gmail dot com
` (7 preceding siblings ...)
2024-02-15 14:09 ` redi at gcc dot gnu.org
@ 2024-02-15 14:54 ` gieseanw+gcc at gmail dot com
8 siblings, 0 replies; 10+ messages in thread
From: gieseanw+gcc at gmail dot com @ 2024-02-15 14:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99546
--- Comment #9 from Andrew Giese <gieseanw+gcc at gmail dot com> ---
(In reply to Jonathan Wakely from comment #8)
> The OP's example is supposed to be ill-formed though, it shouldn't compile
> successfully. So I don't think it's fixed.
That's my mistake, sorry. Yes the second static assertion should definitely
fail.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-02-15 14:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 8:49 [Bug c++/99546] New: Weird return value of C++20 requires expression hewillk at gmail dot com
2021-03-11 8:57 ` [Bug c++/99546] " hewillk at gmail dot com
2021-03-11 13:35 ` redi at gcc dot gnu.org
2021-03-11 15:30 ` redi at gcc dot gnu.org
2021-03-20 8:35 ` hewillk at gmail dot com
2022-09-20 10:09 ` redi at gcc dot gnu.org
2022-09-20 10:15 ` redi at gcc dot gnu.org
2024-02-15 13:58 ` gieseanw+gcc at gmail dot com
2024-02-15 14:09 ` redi at gcc dot gnu.org
2024-02-15 14:54 ` gieseanw+gcc at gmail dot com
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).