public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "development at jordi dot vilar.cat" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/107390] New: template-nested lambda type uniqueness
Date: Tue, 25 Oct 2022 09:52:41 +0000	[thread overview]
Message-ID: <bug-107390-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 107390
           Summary: template-nested lambda type uniqueness
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: development at jordi dot vilar.cat
  Target Milestone: ---

type obtained from a lambda (with c++20 decltype()) nested into a template
(either class o function) is not resolved as a unique type, making this simple
code to fail (compiled with g++-12 -std=c++20):

#include <type_traits>

template<typename> struct test1
{
    using type0 = decltype([]{});
    using type1 = std::type_identity_t<type0>;

    static_assert(std::is_same_v<type0, type1>);
};

template<typename> void test2()
{
    using type0 = decltype([]{});
    using type1 = std::type_identity_t<type0>;

    static_assert(std::is_same_v<type0, type1>);
}

int main(int, char**)
{
    test1<void>{};
    test2<void>();
}

both static_assert fail identically:

 error: static assertion failed
    8 |     static_assert(std::is_same_v<type0, type1>);
      |                   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
<source>:8:24: note: 'std::is_same_v<test1<void>::<lambda()>,
test1<void>::<lambda()> >' evaluates to false
<source>:16:24: error: static assertion failed
   16 |     static_assert(std::is_same_v<type0, type1>);
      |                   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
<source>:16:24: note: 'std::is_same_v<test2<void>()::<lambda()>,
test2<void>()::<lambda()> >' evaluates to false

This compiles correctly if lambdas are not nested inside a template.

             reply	other threads:[~2022-10-25  9:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25  9:52 development at jordi dot vilar.cat [this message]
2022-10-25  9:55 ` [Bug c++/107390] " development at jordi dot vilar.cat
2022-10-25 19:23 ` marxin 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-107390-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).