public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/69623] Invalid deduction of non-trailing template parameter pack
       [not found] <bug-69623-4@http.gcc.gnu.org/bugzilla/>
@ 2021-08-12  1:16 ` pinskia at gcc dot gnu.org
  2021-08-12  1:17 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-12  1:16 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smw at gcc dot gnu.org

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 83870 has been marked as a duplicate of this bug. ***

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

* [Bug c++/69623] Invalid deduction of non-trailing template parameter pack
       [not found] <bug-69623-4@http.gcc.gnu.org/bugzilla/>
  2021-08-12  1:16 ` [Bug c++/69623] Invalid deduction of non-trailing template parameter pack pinskia at gcc dot gnu.org
@ 2021-08-12  1:17 ` pinskia at gcc dot gnu.org
  2021-12-16  4:00 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-12  1:17 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kariya_mitsuru at hotmail dot com

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 61953 has been marked as a duplicate of this bug. ***

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

* [Bug c++/69623] Invalid deduction of non-trailing template parameter pack
       [not found] <bug-69623-4@http.gcc.gnu.org/bugzilla/>
  2021-08-12  1:16 ` [Bug c++/69623] Invalid deduction of non-trailing template parameter pack pinskia at gcc dot gnu.org
  2021-08-12  1:17 ` pinskia at gcc dot gnu.org
@ 2021-12-16  4:00 ` pinskia at gcc dot gnu.org
  2021-12-16  4:00 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-16  4:00 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xmh970252187 at gmail dot com

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 103740 has been marked as a duplicate of this bug. ***

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

* [Bug c++/69623] Invalid deduction of non-trailing template parameter pack
       [not found] <bug-69623-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-12-16  4:00 ` pinskia at gcc dot gnu.org
@ 2021-12-16  4:00 ` pinskia at gcc dot gnu.org
  2022-03-14 14:26 ` ed at catmur dot uk
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-16  4:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Full testcase where both declarations should be an error:

  template<class... T, class... U> void f() { } // error
  template<class... T, class U> void g() { } // error

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

* [Bug c++/69623] Invalid deduction of non-trailing template parameter pack
       [not found] <bug-69623-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2021-12-16  4:00 ` pinskia at gcc dot gnu.org
@ 2022-03-14 14:26 ` ed at catmur dot uk
  2022-03-15  1:59 ` xmh970252187 at gmail dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: ed at catmur dot uk @ 2022-03-14 14:26 UTC (permalink / raw)
  To: gcc-bugs

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

Ed Catmur <ed at catmur dot uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ed at catmur dot uk

--- Comment #6 from Ed Catmur <ed at catmur dot uk> ---
There is a fairly well-known idiom for extracting a specific element of an
argument pack:

auto f(auto..., auto a, auto...) { return a; }
template<auto> struct any { any(auto) {} };
template<std::size_t... I>
auto g(std::index_sequence<I...>, auto... a) { return f<any<I>...>(a...); }
template<unsigned I>
auto h(auto... a) { return g(std::make_index_sequence<I>(), a...); }

I believe the intent of http://eel.is/c++draft/temp#param-14.sentence-3 is that
this idiom should work; per http://eel.is/c++draft/temp#param-example-7 (as in
comment #5) a function template secondary template parameter pack is only
disallowed if it is nondeducible.  In the original description of this ticket
(not comment #5, which I agree is disallowed) T is specifiable and U is
deducible, so both are OK.

> [...] A template parameter pack of a function template shall not be followed by another template parameter unless that template parameter can be deduced from the parameter-type-list ([dcl.fct]) of the function template or has a default argument ([temp.deduct]). [...]

Or is the intent that T must be explicitly specified, i.e. that f can be called
as f<>() but not as f(), pace
http://eel.is/c++draft/temp#arg.explicit-4.sentence-3 ?

> If all of the template arguments can be deduced, they may all be omitted; in this case, the empty template argument list <> itself may also be omitted.

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

* [Bug c++/69623] Invalid deduction of non-trailing template parameter pack
       [not found] <bug-69623-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2022-03-14 14:26 ` ed at catmur dot uk
@ 2022-03-15  1:59 ` xmh970252187 at gmail dot com
  2022-03-15 11:03 ` ed at catmur dot uk
  2022-03-15 14:23 ` xmh970252187 at gmail dot com
  7 siblings, 0 replies; 8+ messages in thread
From: xmh970252187 at gmail dot com @ 2022-03-15  1:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from jim x <xmh970252187 at gmail dot com> ---
In a simple way, the rule just requires that, for a function template, the
template parameter that is declared after a template parameter pack should
either appear in the parameter-declaration-clause before the template
pack(deducible) or just have a default argument.

````
auto f(auto..., auto a, auto...) { return a; }
````
IIUC, this is just disallowed since all arguments would only match the first
function parameter pack.

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

* [Bug c++/69623] Invalid deduction of non-trailing template parameter pack
       [not found] <bug-69623-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2022-03-15  1:59 ` xmh970252187 at gmail dot com
@ 2022-03-15 11:03 ` ed at catmur dot uk
  2022-03-15 14:23 ` xmh970252187 at gmail dot com
  7 siblings, 0 replies; 8+ messages in thread
From: ed at catmur dot uk @ 2022-03-15 11:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Ed Catmur <ed at catmur dot uk> ---
(In reply to jim x from comment #7)
> ````
> auto f(auto..., auto a, auto...) { return a; }
> ````
> IIUC, this is just disallowed since all arguments would only match the first
> function parameter pack.

Maybe? But all 4 major compilers currently permit it (with identical behavior),
so is it worth breaking existing code by disallowing it?

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

* [Bug c++/69623] Invalid deduction of non-trailing template parameter pack
       [not found] <bug-69623-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2022-03-15 11:03 ` ed at catmur dot uk
@ 2022-03-15 14:23 ` xmh970252187 at gmail dot com
  7 siblings, 0 replies; 8+ messages in thread
From: xmh970252187 at gmail dot com @ 2022-03-15 14:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from jim x <xmh970252187 at gmail dot com> ---
After reading [temp.deduct.call] p1 more carefully, I think you're right. Since
the first function parameter pack does not participate in template argument
deduction, the deduction will start to perform from the second function
parameter to the last.

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

end of thread, other threads:[~2022-03-15 14:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-69623-4@http.gcc.gnu.org/bugzilla/>
2021-08-12  1:16 ` [Bug c++/69623] Invalid deduction of non-trailing template parameter pack pinskia at gcc dot gnu.org
2021-08-12  1:17 ` pinskia at gcc dot gnu.org
2021-12-16  4:00 ` pinskia at gcc dot gnu.org
2021-12-16  4:00 ` pinskia at gcc dot gnu.org
2022-03-14 14:26 ` ed at catmur dot uk
2022-03-15  1:59 ` xmh970252187 at gmail dot com
2022-03-15 11:03 ` ed at catmur dot uk
2022-03-15 14:23 ` xmh970252187 at gmail dot com

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