public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nickhuang99 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/102721] New: out-of-line member function definition fails to allow lambda in unevaluated-context of  new feature in c++20
Date: Tue, 12 Oct 2021 23:23:27 +0000	[thread overview]
Message-ID: <bug-102721-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 102721
           Summary: out-of-line member function definition fails to allow
                    lambda in unevaluated-context of  new feature in c++20
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nickhuang99 at hotmail dot com
  Target Milestone: ---

The following snippet code exposes that GCC parser doesn't comply with c++20
standard to allow lambda in unevaluated context. It seems this out-of-line
definition creates a new lambda type where lambda as operand of "decltype"
should be treated as in unevaluated context. So, it shouldn't create a new
lambda type in out-of-line definition.

Both clang and MSVC++ (https://www.godbolt.org/z/EMbb44fd8) parse this
correctly.
(with "-std=c++20")

template<class T>
struct A
{    
    void foo(const T){}
};

template<>
void A<decltype(+[]{})[3]>::foo(const decltype(+[]{})[3])
{}




<source>:9:6: error: ambiguating new declaration of 'void A<void (*
[3])()>::foo(void (* const*)())'
    9 | void A<decltype(+[]{})[3]>::foo(const decltype(+[]{})[3])
      |      ^~~~~~~~~~~~~~~~~~~~~
<source>:5:10: note: old declaration 'void A<T>::foo(T) [with T = void (*
[3])()]'
    5 |     void foo(const T){}
      |          ^~~

             reply	other threads:[~2021-10-12 23:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12 23:23 nickhuang99 at hotmail dot com [this message]
2021-10-12 23:33 ` [Bug c++/102721] " pinskia at gcc dot gnu.org
2021-10-12 23:35 ` pinskia at gcc dot gnu.org
2021-10-12 23:37 ` pinskia at gcc dot gnu.org
2021-10-13  8:51 ` nickhuang99 at hotmail dot com
2021-10-13 11:59 ` nickhuang99 at hotmail 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-102721-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).