[LLVMbugs] [Bug 21628] New: Increase limit of parameters in variadic template packs?
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Nov 21 02:01:45 PST 2014
http://llvm.org/bugs/show_bug.cgi?id=21628
Bug ID: 21628
Summary: Increase limit of parameters in variadic template
packs?
Product: clang
Version: 3.5
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: dimanne at ya.ru
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
template <class TUndInt, class TV>
constexpr TUndInt CalcMax(TV V) noexcept { return static_cast<TUndInt>(V); }
template <class TUndInt, class TV, class ...TVs>
constexpr TUndInt CalcMax(TV V, TVs... Vs) noexcept {
return static_cast<TUndInt>(V) > CalcMax<TUndInt>(Vs...) ?
static_cast<TUndInt>(V) : CalcMax<TUndInt>(Vs...);
}
template <class TVs, TVs... Vs>
class TClass {
static const auto MaxNotInc = CalcMax<TVs>(Vs...) + 1;
};
int main() {
TClass<int, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
> Object;
return 0;
}
If you shall try to compile above example, you get following error message:
$ clang++ --std=c++11 main.cpp
main.cpp:2:42: error: in-class initializer for static data member is not a
constant expression
constexpr TUndInt CalcMax(TV V) noexcept { return static_cast<TUndInt>(V); }
^
main.cpp:17:70: note: in instantiation of template class
'TClass<int, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24>' requested here
> Object;
^
1 error generated.
but it you decrease number of parameters by commenting out this line
, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
all works well.
$ clang++ --version
Ubuntu clang version 3.5.0-4ubuntu2 (tags/RELEASE_350/final) (based on LLVM
3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ uname -a
Linux DimanNeYa 3.16.0-24-generic #32-Ubuntu SMP Tue Oct 28 13:07:32 UTC 2014
x86_64 x86_64 x86_64 GNU/Linux
--
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/20141121/b9142cfa/attachment.html>
More information about the llvm-bugs
mailing list