public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/99546] Weird return value of C++20 requires expression
Date: Tue, 20 Sep 2022 10:15:06 +0000 [thread overview]
Message-ID: <bug-99546-4-Pimm5nMO8y@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99546-4@http.gcc.gnu.org/bugzilla/>
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:
next prev parent reply other threads:[~2022-09-20 10:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-11 8:49 [Bug c++/99546] New: " 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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-99546-4-Pimm5nMO8y@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).