mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 512297 - Decrease the template instantiation depth limit to 128
The previous limit of 256 was not sufficient to prevent stack overflows in some cases. Change-Id: Ied9171ed3020f2de7932fa9ee50780bd207d8707
This commit is contained in:
parent
98e1153ba0
commit
89ebafa72e
2 changed files with 31 additions and 1 deletions
|
@ -10434,4 +10434,34 @@ public class AST2TemplateTests extends AST2CPPTestBase {
|
|||
assertNotNull(problem);
|
||||
assertEquals(IProblem.TEMPLATE_ARGUMENT_NESTING_DEPTH_LIMIT_EXCEEDED, problem.getID());
|
||||
}
|
||||
|
||||
// template<class... Ts>
|
||||
// struct infinite;
|
||||
//
|
||||
// template<class Infinite, int N>
|
||||
// struct infinite_generator {
|
||||
// typedef infinite<typename infinite_generator<Infinite, N-1>::type> type;
|
||||
// };
|
||||
//
|
||||
// template<class Infinite>
|
||||
// struct infinite_generator<Infinite, 0> {
|
||||
// typedef Infinite type;
|
||||
// };
|
||||
//
|
||||
// template<class... Ts>
|
||||
// struct infinite {
|
||||
// typedef infinite<Ts...> self_type;
|
||||
//
|
||||
// template<int N>
|
||||
// static typename infinite_generator<self_type, N>::type generate() {
|
||||
// return typename infinite_generator<self_type, N>::type();
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// auto parser_killer_2 = infinite<int>::generate<400>();
|
||||
public void testTemplateInstantiationDepthLimit_512297() throws Exception {
|
||||
CPPASTNameBase.sAllowRecursionBindings = true;
|
||||
BindingAssertionHelper helper = getAssertionHelper();
|
||||
helper.assertProblem("generate<400>", "generate<400>");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@ public class CPPTemplates {
|
|||
static enum TypeSelection { PARAMETERS, RETURN_TYPE, PARAMETERS_AND_RETURN_TYPE }
|
||||
|
||||
// Infrastructure to protect against rogue template metaprograms that don't terminate.
|
||||
private static final int TEMPLATE_INSTANTIATION_DEPTH_LIMIT = 256;
|
||||
private static final int TEMPLATE_INSTANTIATION_DEPTH_LIMIT = 128;
|
||||
private static final ThreadLocal<Integer> fTemplateInstantiationDepth = new ThreadLocal<Integer>() {
|
||||
@Override
|
||||
protected Integer initialValue() {
|
||||
|
|
Loading…
Add table
Reference in a new issue