llvm-project/libcxx
Eric Fiselier 295bce1130 [libcxx] Delay evaluation of __make_tuple_types to prevent blowing the max template instantiation depth. Fixes Bug #18345
Summary:
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 .


Test Plan: Two tests have been added. One for the "tuple-like" constructors and another for the "tuple-like" assignment operator. 

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: K-ballo, cfe-commits

Differential Revision: http://reviews.llvm.org/D4467

llvm-svn: 220769
2014-10-28 06:31:22 +00:00
..
cmake [libcxx] Redo adding support for building and testing with an ABI library not along linker paths 2014-10-19 00:42:41 +00:00
include [libcxx] Delay evaluation of __make_tuple_types to prevent blowing the max template instantiation depth. Fixes Bug #18345 2014-10-28 06:31:22 +00:00
lib [libcxx] Redo adding support for building and testing with an ABI library not along linker paths 2014-10-19 00:42:41 +00:00
src PR #21321 talked about implementation-defined behavior of realloc. I poo-poohed it, and was wrong. Fix the call in <locale>. Review the others, refactored some duplicated code, and found overflow bugs (and __event_cap_ was never getting updated, either). 2014-10-27 19:08:10 +00:00
test [libcxx] Delay evaluation of __make_tuple_types to prevent blowing the max template instantiation depth. Fixes Bug #18345 2014-10-28 06:31:22 +00:00
www Remove dead buildbot link 2014-10-21 02:46:31 +00:00
.arcconfig Update Arcanist config to point to reviews.llvm.org 2014-06-10 18:29:36 +00:00
CMakeLists.txt [libcxx] Add support for building and testing with an ABI library not along linker paths 2014-10-18 01:15:17 +00:00
CREDITS.TXT Add self to credits 2014-08-21 04:21:43 +00:00
LICENSE.TXT Update the copyright credits -- Happy new year 2014! 2014-01-01 08:27:31 +00:00
Makefile Exclude .svn (and other "dot" directories) when installing headers. 2014-03-13 16:13:54 +00:00