From cd583fe1808bbe2d06cc55b8213e2c39a66f200f Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 5 Aug 2015 10:01:12 +0000 Subject: [PATCH] re PR tree-optimization/67055 (Segmentation fault in fold_builtin_alloca_with_align in tree-ssa-ccp.c) 2015-08-05 Richard Biener PR tree-optimization/67055 * tree-ssa-ccp.c (fold_builtin_alloca_with_align): Handle NULL gimple_block. * g++.dg/torture/pr67055.C: New testcase. From-SVN: r226616 --- gcc/ChangeLog | 8 +++++ gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/g++.dg/torture/pr67055.C | 44 ++++++++++++++++++++++++++ gcc/tree-ssa-ccp.c | 1 + 4 files changed, 58 insertions(+) create mode 100644 gcc/testsuite/g++.dg/torture/pr67055.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f6717cda275..ff02e192470 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-08-05 Richard Biener + + PR tree-optimization/67055 + * tree-ssa-ccp.c (fold_builtin_alloca_with_align): Handle + NULL gimple_block. + + * g++.dg/torture/pr67055.C: New testcase. + 2015-08-05 Kirill Yukhin * config/i386/i386.md (define_attr "isa"): Addd avx512vl and diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 82aa267d42d..e7e74a36b25 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-08-05 Richard Biener + + PR tree-optimization/67055 + * g++.dg/torture/pr67055.C: New testcase. + 2015-08-05 Richard Biener PR tree-optimization/67109 diff --git a/gcc/testsuite/g++.dg/torture/pr67055.C b/gcc/testsuite/g++.dg/torture/pr67055.C new file mode 100644 index 00000000000..7cbbca275c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr67055.C @@ -0,0 +1,44 @@ +// { dg-do compile } +// { dg-additional-options "-std=c++14" } + +namespace std { + typedef __SIZE_TYPE__ size_t; + struct nothrow_t; +} +namespace vespamalloc { + void fn1(void *); + template class A { + public: + static unsigned long fillStack(unsigned long); + }; + template + unsigned long A::fillStack(unsigned long p1) { + void *retAddr[p1]; + fn1(retAddr); + } + class B { + protected: + B(void *); + }; + template class D : B { + public: + D() : B(0) {} + void alloc(int) { A::fillStack(StackTraceLen); } + }; + template class C { + public: + void *malloc(unsigned long); + }; + template + void *C::malloc(unsigned long) { + MemBlockPtrT mem; + mem.alloc(0); + } + C, int> *_GmemP; +} +void *operator new(std::size_t, std::nothrow_t &) noexcept { + return vespamalloc::_GmemP->malloc(0); +} +void *operator new[](std::size_t, std::nothrow_t &) noexcept { + return vespamalloc::_GmemP->malloc(0); +} diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index a18caa1bf3c..398ddc1e041 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -2107,6 +2107,7 @@ fold_builtin_alloca_with_align (gimple stmt) as a declared array, so we allow a larger size. */ block = gimple_block (stmt); if (!(cfun->after_inlining + && block && TREE_CODE (BLOCK_SUPERCONTEXT (block)) == FUNCTION_DECL)) threshold /= 10; if (size > threshold) -- 2.30.2