http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58527

--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
(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<class ... Types> void f(Types& ...);
template<class T1, class ... Types> void g(T1, Types ...);
template<class T1, class ... Types> 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<int, int, int>(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.

Reply via email to