public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ed at catmur dot uk" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/112354] New: mismatched types 'B<T>' and 'B<int>&' for generic lambda noexcept-specifier referencing enclosing function parameter
Date: Thu, 02 Nov 2023 18:24:36 +0000	[thread overview]
Message-ID: <bug-112354-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 112354
           Summary: mismatched types 'B<T>' and 'B<int>&' for generic
                    lambda noexcept-specifier referencing enclosing
                    function parameter
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ed at catmur dot uk
  Target Milestone: ---

Since 4.9.0,

template<class>
struct B {
    B();
    B(B const&);
};
template<class T> void g(B<T>, int);
auto f(B<int> x) {
    return [](auto y) noexcept(noexcept(g(x, y))) {
        return 1;
    };
}
int i = f({})(0);

fails with:

<source>: In instantiation of 'f(B<int>)::<lambda(auto:1)> [with auto:1 =
int]':
<source>:12:14:   required from here
   12 | int i = f({})(0);
      |         ~~~~~^~~
<source>:8:42: error: no matching function for call to 'g(B<int>&&, int&)'
    8 |     return [](auto y) noexcept(noexcept(g(x, y))) {
      |                                         ~^~~~~~
<source>:6:24: note: candidate: 'template<class T> void g(B<T>, int)'
    6 | template<class T> void g(B<T>, int);
      |                        ^
<source>:6:24: note:   template argument deduction/substitution failed:
<source>:8:42: note:   mismatched types 'B<T>' and 'B<int>&'
    8 |     return [](auto y) noexcept(noexcept(g(x, y))) {
      |                                         ~^~~~~~

             reply	other threads:[~2023-11-02 18:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02 18:24 ed at catmur dot uk [this message]
2023-11-02 18:33 ` [Bug c++/112354] " pinskia 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-112354-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).