[Bug c++/58527] Failures when a function parameter pack is not final

2013-10-05 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58527

Paolo Carlini  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #4 from Paolo Carlini  ---
Closing.


[Bug c++/58527] Failures when a function parameter pack is not final

2013-09-25 Thread glisse at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58527

--- Comment #3 from Marc Glisse  ---
(In reply to Nick Maclaren from comment #2)
> I would be interested in a reference to the wording in the standard,
> if you know it offhand.  I failed to find it.

[temp.deduct.call]

For a function parameter pack that occurs at the end of the
parameter-declaration-list, the type A of each remaining argument of the call
is compared with the type P of the declarator-id of the function parameter
pack. Each comparison deduces template arguments for subsequent positions in
the
template parameter packs expanded by the function parameter pack. When a
function parameter pack appears in a non-deduced context (14.8.2.5), the type
of that parameter pack is never deduced. [ Example:

template void f(Types& ...);
template void g(T1, Types ...);
template void g1(Types ..., T1);
void h(int x, float& y) {
const int z = x;
f(x, y, z); // Types is deduced to int, float, const int
g(x, y, z); // T1 is deduced to int; Types is deduced to float, int
g1(x, y, z); // error: Types is not deduced
g1(x, y, z); // OK, no deduction occurs
}

> But that doesn't address the other point.  Even if C++ allows a parameter
> pack in a position where it cannot be deduced (and that would not be at
> all surprising), good practice would be to give at least a warning.

There are perfectly legitimate reasons to write such code, and no way to tell
the compiler that we know what we are doing, so I wouldn't include it in Wall.
But sure, feel free to add a warning for this, it may indeed help.


[Bug c++/58527] Failures when a function parameter pack is not final

2013-09-25 Thread nmm1 at cam dot ac.uk
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58527

--- Comment #2 from Nick Maclaren  ---
Thanks.  I can't use your fix, because I am trying to write a generic
multi-dimensional array class for possible inclusion in the standard,
and demanding such usages from end users is Not On.  There are other
possibilities, of course.

I would be interested in a reference to the wording in the standard,
if you know it offhand.  I failed to find it.

But that doesn't address the other point.  Even if C++ allows a parameter
pack in a position where it cannot be deduced (and that would not be at
all surprising), good practice would be to give at least a warning.  And
I did specify -Wall -Wextra :-)


[Bug c++/58527] Failures when a function parameter pack is not final

2013-09-25 Thread glisse at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58527

--- Comment #1 from Marc Glisse  ---
The parameter pack can only be deduced if it is in last position (that's an
arbitrary restriction, but it is in C++11). However, you can still do:
  weeble(123,456,789,3.1416);