public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nickgray0 at brown dot edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/99961] New: requires clause rejects mentioning of function parameters too early
Date: Wed, 07 Apr 2021 17:37:12 +0000	[thread overview]
Message-ID: <bug-99961-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 99961
           Summary: requires clause rejects mentioning of function
                    parameters too early
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nickgray0 at brown dot edu
  Target Milestone: ---

the following code fails to compile:

    struct A {
        static constexpr auto x = 42;
    };

    auto f(auto a) requires (a.x > 10) {}

    auto main()->int {
        f(A{});
    }

error message: <source>:5:27: error: use of parameter outside function body
before '.' token
    5 | auto f(auto a) requires (a.x > 10) {}
      |                           ^
<source>: In function 'int main()':
<source>:8:6: error: no matching function for call to 'f(A)'
    8 |     f(A{});
      |     ~^~~~~
<source>:5:6: note: candidate: 'template<class auto:1> auto f(auto:1) requires 
<erroneous-expression>'
    5 | auto f(auto a) requires (a.x > 10) {}
      |      ^
<source>:5:6: note:   template argument deduction/substitution failed:
<source>:5:6: note: constraints not satisfied



as shown in the example above, a.x doesn't *actually* make use of a

             reply	other threads:[~2021-04-07 17:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 17:37 nickgray0 at brown dot edu [this message]
2021-04-07 19:35 ` [Bug c++/99961] " redi at gcc dot gnu.org
2021-04-11 15:33 ` ppalka at gcc dot gnu.org
2021-04-13  2:55 ` cvs-commit at gcc dot gnu.org
2021-04-13  2:57 ` ppalka at gcc dot gnu.org
2022-12-13 14:24 ` ppalka 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-99961-4@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).