public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99926] New: Parameter packs and variadic arguments: Clang, gcc, and msvc differ on this one
@ 2021-04-06  7:47 matthurd at acm dot org
  2021-04-06  8:13 ` [Bug c++/99926] " matthurd at acm dot org
  2021-04-17  3:38 ` matthurd at acm dot org
  0 siblings, 2 replies; 3+ messages in thread
From: matthurd at acm dot org @ 2021-04-06  7:47 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/99926] Parameter packs and variadic arguments: Clang, gcc, and msvc differ on this one
  2021-04-06  7:47 [Bug c++/99926] New: Parameter packs and variadic arguments: Clang, gcc, and msvc differ on this one matthurd at acm dot org
@ 2021-04-06  8:13 ` matthurd at acm dot org
  2021-04-17  3:38 ` matthurd at acm dot org
  1 sibling, 0 replies; 3+ messages in thread
From: matthurd at acm dot org @ 2021-04-06  8:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Matt Hurd <matthurd at acm dot org> ---
Just a correction to the commentary. The variadic after the pack is not
unreachable as Richard Smith points out the following code can make the
variadic argument reachable if you wrote such evil and it had a name:


> auto *p = foo<int, int>;
> p(3, 4, 5); // passes the '5' via the C-style variable argument list.

--Matt.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/99926] Parameter packs and variadic arguments: Clang, gcc, and msvc differ on this one
  2021-04-06  7:47 [Bug c++/99926] New: Parameter packs and variadic arguments: Clang, gcc, and msvc differ on this one matthurd at acm dot org
  2021-04-06  8:13 ` [Bug c++/99926] " matthurd at acm dot org
@ 2021-04-17  3:38 ` matthurd at acm dot org
  1 sibling, 0 replies; 3+ messages in thread
From: matthurd at acm dot org @ 2021-04-17  3:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Matt Hurd <matthurd at acm dot org> ---
FWIW, MSVC claims to have fixed their bug in version 16.10 Preview 2, leaving
just gcc generating incorrect code.

https://developercommunity.visualstudio.com/t/parameter-packs-and-variadic-arguments-clang-gcc-a/1390988

--Matt.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-17  3:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06  7:47 [Bug c++/99926] New: Parameter packs and variadic arguments: Clang, gcc, and msvc differ on this one matthurd at acm dot org
2021-04-06  8:13 ` [Bug c++/99926] " matthurd at acm dot org
2021-04-17  3:38 ` matthurd at acm dot org

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).