public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix PR67055
Date: Wed, 05 Aug 2015 09:55:00 -0000	[thread overview]
Message-ID: <alpine.LSU.2.11.1508051153420.19642@zhemvz.fhfr.qr> (raw)


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  <rguenther@suse.de>

	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 <typename> class A {
+    public:
+	static unsigned long fillStack(unsigned long);
+    };
+    template <typename StackRep>
+	unsigned long A<StackRep>::fillStack(unsigned long p1) {
+	    void *retAddr[p1];
+	    fn1(retAddr);
+	}
+    class B {
+    protected:
+	B(void *);
+    };
+    template <int StackTraceLen> class D : B {
+    public:
+	D() : B(0) {}
+	void alloc(int) { A<int>::fillStack(StackTraceLen); }
+    };
+    template <typename, typename> class C {
+    public:
+	void *malloc(unsigned long);
+    };
+    template <typename MemBlockPtrT, typename ThreadListT>
+	void *C<MemBlockPtrT, ThreadListT>::malloc(unsigned long) {
+	    MemBlockPtrT mem;
+	    mem.alloc(0);
+	}
+    C<D<16>, 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);
+}

                 reply	other threads:[~2015-08-05  9:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.11.1508051153420.19642@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).