[PATCH] [libcxx] Delay evaluation of __make_tuple_types to prevent blowing the max template instantiation depth. Fixes Bug #18345
Eric Fiselier
eric at efcs.ca
Thu Jul 10 16:51:56 PDT 2014
Hi mclow.lists,
http://llvm.org/bugs/show_bug.cgi?id=18345
Tuple's constructor and assignment operators for "tuple-like" types evaluates __make_tuple_types unnecessarily. In the case of a large array this can blow the template instantiation depth.
Ex:
```
#include <array>
#include <tuple>
#include <memory>
typedef std::array<int, 1256> array_t;
typedef std::tuple<array_t> tuple_t;
int main() {
array_t a;
tuple_t t(a); // broken
t = a; // broken
// make_shared uses tuple behind the scenes. This bug breaks this code.
std::make_shared<array_t>(a);
}
```
To prevent this from happening we delay the instantiation of `__make_tuple_types` until after we perform the length check. Currently `__make_tuple_types` is instantiated at the same time that the length check .
http://reviews.llvm.org/D4467
Files:
include/__tuple
test/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp
test/utilities/tuple/tuple.tuple/tuple.cnstr/tuple_array_template_depth.pass.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4467.11300.patch
Type: text/x-patch
Size: 8553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140710/a96acac4/attachment.bin>
More information about the cfe-commits
mailing list