[llvm-bugs] [Bug 26357] New: Incorrect deduction of parameter pack
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jan 28 09:01:30 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26357
Bug ID: 26357
Summary: Incorrect deduction of parameter pack
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: ldionne.2 at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
The following code fails to compile on Clang trunk:
------------------------------------------------------------------------------
#include <cstddef>
#include <utility>
template <std::size_t I, typename T>
struct elt { };
template <typename Indices, typename ...T>
struct indexer;
template <std::size_t ...I, typename ...T>
struct indexer<std::index_sequence<I...>, T...>
: elt<I, T>...
{ };
template <typename ...T>
struct types { };
template <std::size_t ...I, typename ...T>
types<T...> slice_types(elt<I, T> const& ...);
struct x0; struct x1; struct x2; struct x3;
using Indexer = indexer<std::index_sequence<0, 1, 2, 3>, x0, x1, x2, x3>;
using Slice = decltype(slice_types<1, 2>(Indexer{},Indexer{}));
------------------------------------------------------------------------------
The error is
prog.cc:25:24: error: no matching function for call to 'slice_types'
using Slice = decltype(slice_types<1, 2>(Indexer{},Indexer{}));
^~~~~~~~~~~~~~~~~
prog.cc:20:13: note: candidate template ignored: deduced type 'const elt<1UL,
x3> &' of 1st parameter does not match adjusted type 'Indexer' (aka
'indexer<std::__1::integer_sequence<unsigned long, 0, 1, 2, 3>, x0, x1, x2,
x3>') of argument [with I = <1, 2>, T = <x3, x3>]
types<T...> slice_types(elt<I, T> const& ...);
^
1 error generated.
It seems like the `T...` parameter pack is wrongly deduced to `x3, x3` in the
`slice_types` function. GCC accepts this code and does the right thing.
Live example: http://melpon.org/wandbox/permlink/5rsGlLeQbKgiLXqM
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160128/a7838e58/attachment.html>
More information about the llvm-bugs
mailing list