public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dimitri.gorokhovik at free dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/97572] [c++ 20] Constraining is broken
Date: Mon, 26 Oct 2020 10:45:08 +0000	[thread overview]
Message-ID: <bug-97572-4-W5Qu8goBb2@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-97572-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97572

--- Comment #2 from Dimitri Gorokhovik <dimitri.gorokhovik at free dot fr> ---
Fair enough, passing a boolean by value into 'any()' is evaluation of local
parameter 't', and that is prohibited (7.5.7.4/2). 

Doesn't this merit a better diagnostics though?

A slightly modified code:

constexpr bool any (bool) { return true; };
template <typename T> concept Any = requires (T t) { requires any (t); };
static_assert (Any <bool>);

produces:

constexpr bool any(bool)
<stdin>:2:63: error: ‘t’ is not a constant expression
<stdin>: At global scope:
<stdin>:3:16: error: static assertion failed
<stdin>:3:16: note: constraints not satisfied
<stdin>:2:31:   required by the constraints of ‘template<class T> concept Any’
<stdin>:2:37:   in requirements with ‘T t’ [with T = bool]
<stdin>:2:63: error: ‘t’ is not a constant expression
<stdin>:2:67: note: nested requirement ‘any(t)’ is not satisfied, because
<stdin>:2:68: error: cannot convert ‘T’ to ‘bool’
<stdin>:1:21: note:   initializing argument 1 of ‘constexpr bool any(bool)’

which completely leads to believe that the culprit is in the line 2 whereas it
is in the line 1 (which doesn't even have a 't')?

  parent reply	other threads:[~2020-10-26 10:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-25 19:21 [Bug c++/97572] New: " dimitri.gorokhovik at free dot fr
2020-10-25 22:06 ` [Bug c++/97572] " redi at gcc dot gnu.org
2020-10-26 10:45 ` dimitri.gorokhovik at free dot fr [this message]
2020-10-26 11:37 ` redi at gcc dot gnu.org
2020-10-26 12:22 ` dimitri.gorokhovik at free dot fr
2021-04-27 10:22 ` redi at gcc dot gnu.org
2021-04-27 10:27 ` redi at gcc dot gnu.org

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-97572-4-W5Qu8goBb2@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).