From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108515 invoked by alias); 5 Aug 2015 09:55:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 108506 invoked by uid 89); 5 Aug 2015 09:55:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,KAM_ASCII_DIVIDERS,RP_MATCHES_RCVD,SPF_PASS autolearn=no version=3.3.2 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 05 Aug 2015 09:55:03 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A8C5CAD17 for ; Wed, 5 Aug 2015 09:55:00 +0000 (UTC) Date: Wed, 05 Aug 2015 09:55:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR67055 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2015-08/txt/msg00249.txt.bz2 The inliner decides sth stupid here (IMHO - inlining a function into a thunk) but at least we shouldn't crash (the tailcall in the thunk has no BLOCK associated with it). Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 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. Index: gcc/tree-ssa-ccp.c =================================================================== --- gcc/tree-ssa-ccp.c (revision 226577) +++ gcc/tree-ssa-ccp.c (working copy) @@ -2107,6 +2120,7 @@ fold_builtin_alloca_with_align (gimple s 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) Index: gcc/testsuite/g++.dg/torture/pr67055.C =================================================================== --- gcc/testsuite/g++.dg/torture/pr67055.C (revision 0) +++ gcc/testsuite/g++.dg/torture/pr67055.C (working copy) @@ -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); +}