public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "matthurd at acm dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/99926] New: Parameter packs and variadic arguments: Clang, gcc, and msvc differ on this one
Date: Tue, 06 Apr 2021 07:47:41 +0000	[thread overview]
Message-ID: <bug-99926-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 99926
           Summary: Parameter packs and variadic arguments: Clang, gcc,
                    and msvc differ on this one
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matthurd at acm dot org
  Target Milestone: ---

I found three compiler differences from three compilers:
https://godbolt.org/z/cEoYrn4T8 - two are wrong.

g++ trunk and 10.2 affected.

I thought gcc may be correct and clang may be incorrect in this compiler
difference so I filed a bug with llvm. Richard Smith surmised gcc was incorrect
and clang is correct, so I have closed the clang bug and I'm opening a gcc bug
here if you'll indulge me.

[Note: clang issue: https://bugs.llvm.org/show_bug.cgi?id=49852]

________________


gcc, clang, and msvc all compile this fun one:

auto foo(auto......) { return 42; }
int add_three() { return foo<int,int>(3,4,5); }

____________________

But they argue about this curious one:

[[nodiscard]] constexpr auto foo(auto...t...) noexcept {return (... + t);}
int add_three() { return foo<int,int>(3,4,5);} //gcc(7),  clang(12), msvc(err)
int add_more()  { return foo(3,4,5,6);       } //gcc(18), clang(18), msvc(err)

https://godbolt.org/z/cEoYrn4T8
____________________

It looks like gcc may be failing to extend the deduction as clang does. Like
clang, EDG extends it as well, Richard reported. msvc will give the same answer
as clang if auto is not used and it is a normal template expansion. This leaves
gcc as the outlier I guess.


That gcc may be wrong makes sense, though it makes a C-style variadic after a
parameter pack unreachable which is a wee semantic whole in the grammar I
guess.

--Matt.

             reply	other threads:[~2021-04-06  7:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-06  7:47 matthurd at acm dot org [this message]
2021-04-06  8:13 ` [Bug c++/99926] " matthurd at acm dot org
2021-04-17  3:38 ` matthurd at acm dot 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-99926-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).