[Bug c++/69623] Invalid deduction of non-trailing template parameter pack

2022-03-15 Thread xmh970252187 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69623

--- Comment #9 from jim x  ---
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.

[Bug c++/69623] Invalid deduction of non-trailing template parameter pack

2022-03-15 Thread ed at catmur dot uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69623

--- Comment #8 from Ed Catmur  ---
(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?

[Bug c++/69623] Invalid deduction of non-trailing template parameter pack

2022-03-14 Thread xmh970252187 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69623

--- Comment #7 from jim x  ---
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.

[Bug c++/69623] Invalid deduction of non-trailing template parameter pack

2022-03-14 Thread ed at catmur dot uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69623

Ed Catmur  changed:

   What|Removed |Added

 CC||ed at catmur dot uk

--- Comment #6 from Ed Catmur  ---
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 struct any { any(auto) {} };
template
auto g(std::index_sequence, auto... a) { return f...>(a...); }
template
auto h(auto... a) { return g(std::make_index_sequence(), 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.

[Bug c++/69623] Invalid deduction of non-trailing template parameter pack

2021-12-15 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69623

--- Comment #5 from Andrew Pinski  ---
Full testcase where both declarations should be an error:

  template void f() { } // error
  template void g() { } // error

[Bug c++/69623] Invalid deduction of non-trailing template parameter pack

2021-12-15 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69623

Andrew Pinski  changed:

   What|Removed |Added

 CC||xmh970252187 at gmail dot com

--- Comment #4 from Andrew Pinski  ---
*** Bug 103740 has been marked as a duplicate of this bug. ***

[Bug c++/69623] Invalid deduction of non-trailing template parameter pack

2021-08-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69623

Andrew Pinski  changed:

   What|Removed |Added

 CC||kariya_mitsuru at hotmail dot 
com

--- Comment #3 from Andrew Pinski  ---
*** Bug 61953 has been marked as a duplicate of this bug. ***

[Bug c++/69623] Invalid deduction of non-trailing template parameter pack

2021-08-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69623

Andrew Pinski  changed:

   What|Removed |Added

 CC||smw at gcc dot gnu.org

--- Comment #2 from Andrew Pinski  ---
*** Bug 83870 has been marked as a duplicate of this bug. ***

[Bug c++/69623] Invalid deduction of non-trailing template parameter pack

2016-08-21 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69623

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-08-21
 Ever confirmed|0   |1

--- Comment #1 from Andrew Pinski  ---
Confirmed.