This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR63649


When assigning symbols to sections in ipa-comdats.c we currently
segfault when val is NULL. Fix by guarding against this case.

Tested on powerpc64-unknown-linux-gnu.
OK for trunk?

2014-10-27  Markus Trippelsdorf  <markus@trippelsdorf.de> 

	PR ipa/63649
	* ipa-comdats.c (ipa_comdats): Guard against NULL.

	PR ipa/63649
	* g++.dg/ipa/pr63649.C: New test.

diff --git a/gcc/ipa-comdats.c b/gcc/ipa-comdats.c
index b270d9717b27..8843410545e0 100644
--- a/gcc/ipa-comdats.c
+++ b/gcc/ipa-comdats.c
@@ -317,8 +317,11 @@ ipa_comdats (void)
 	  && !symbol->alias
 	  && symbol->real_symbol_p ())
 	{
-	  tree group = *map.get (symbol);
+	  tree *val = map.get (symbol);
+	  if (!val)
+	    continue;
 
+	  group = *val;
 	  if (group == error_mark_node)
 	    continue;
 	  if (dump_file)
diff --git a/gcc/testsuite/g++.dg/ipa/pr63649.C b/gcc/testsuite/g++.dg/ipa/pr63649.C
new file mode 100644
index 000000000000..1bd1d13aaaf3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr63649.C
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -std=c++11"  } */
+struct A
+{
+  typedef void Func ();
+  A () = default;
+  void *_base;
+};
+class B
+{
+  struct
+  {
+    void m_fn1 (A::Func);
+  } static b;
+};
+template <typename> class C : B
+{
+public:
+  C ();
+  static void
+  m_fn2 ()
+  {
+  }
+};
+
+A c;
+__attribute__ ((init_priority (0xfffe))) C<int> a;
+template <typename T> C<T>::C () { b.m_fn1 (m_fn2); }
-- 
Markus


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]