public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "foom at fuhm dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/98804] New: GCC misparses template in pack expansion as comparison
Date: Sat, 23 Jan 2021 16:01:10 +0000	[thread overview]
Message-ID: <bug-98804-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 98804
           Summary: GCC misparses template in pack expansion as comparison
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: foom at fuhm dot net
                CC: richard-gccbugzilla at metafoo dot co.uk
  Target Milestone: ---

GCC parses the following program (by Richard Smith) as `g` less-than `a`
greater-than `(a)` instead of a call to the function `g` with template-args
`a`, and argument-list `(a)`. And thus, it fails to compile.

(Compile with -std=c++20)
----
struct X { constexpr X(int&) {} };
template<class F> void g(F);
template<X> void g(int);
void g(...);

template<class ...A> auto h(A ...a)->decltype (g (0, g < a > (a) ...)) {
}

void test () {
  h(0);
}
-----

I originally noticed this bug with the following test from Clang's test-suite,
while working on a mangling bug in Clang. In this original test-case, GCC does
successfully compile, but the mangling is weird, exposing that the same
misparse occurred.

----
namespace pr30440 {
template<class F> void g(F);

template<class ...A> auto h(A ...a)->decltype (g (0, g < a > (a) ...)) {
}
void pr30440_test () {
  h();
}
}
----

GCC mangles as:
_ZN7pr304401hIJEEEDTcl1gLi0Espgtlt1gfp_fp_EEDpT_
                              ^^^^
with greater/less operators in the mangling.

But it should've been:
_ZN7pr304401hIJEEEDTcl1gLi0Espcl1gIXfp_EEfp_EEEDpT_
                                  ^^^^^^^
with a template-arg.

             reply	other threads:[~2021-01-23 16:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-23 16:01 foom at fuhm dot net [this message]
2021-01-24 20:33 ` [Bug c++/98804] " richard-gccbugzilla at metafoo dot co.uk
2021-02-12  4:38 ` mpolacek 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-98804-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).