This is a backport of r194470 to the gcc-4.7 branch. It fixes a case
were n_functions in coverage_obj_finish is 0 and the resulting array
contains 0x100000000 elements.

(Mike Hommey pointed out that Fixefox PGO-build is broken using 4.7
because of this bug)

Bootstrapped and tested on x86_64-unknown-linux-gnu.
OK for gcc-4_7-branch?

---
 gcc/ChangeLog                         |  9 +++++++++
 gcc/coverage.c                        |  3 +++
 gcc/testsuite/ChangeLog               |  9 +++++++++
 gcc/testsuite/g++.dg/other/pr55650.C  | 21 +++++++++++++++++++++
 gcc/testsuite/g++.dg/other/pr55650.cc |  4 ++++
 5 files changed, 46 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/other/pr55650.C
 create mode 100644 gcc/testsuite/g++.dg/other/pr55650.cc

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c8e08cf9a40b..4cfc1b1d0c80 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2014-01-29  Markus Trippelsdorf  <mar...@trippelsdorf.de>
+
+       Backport from mainline
+       2012-12-13  Jakub Jelinek  <ja...@redhat.com>
+
+       PR gcov-profile/55650
+       * coverage.c (coverage_obj_init): Return false if no functions
+       are being emitted.
+
 2014-01-25  Walter Lee  <w...@tilera.com>
 
        Backport from mainline
diff --git a/gcc/coverage.c b/gcc/coverage.c
index c64125ad58b0..8a113a50c2e2 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -988,6 +988,9 @@ coverage_obj_init (void)
       /* The function is not being emitted, remove from list.  */
       *fn_prev = fn->next;
 
+  if (functions_head == NULL)
+    return false;
+
   for (ix = 0; ix != GCOV_COUNTERS; ix++)
     if ((1u << ix) & prg_ctr_mask)
       n_counters++;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a0320c6401b8..152554dcfcda 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2014-01-29  Markus Trippelsdorf  <mar...@trippelsdorf.de>
+
+       Backport from mainline
+       2012-12-13  Jakub Jelinek  <ja...@redhat.com>
+
+       PR gcov-profile/55650
+       * g++.dg/other/pr55650.C: New test.
+       * g++.dg/other/pr55650.cc: New file.
+
 2014-01-26  Mikael Morin  <mik...@gcc.gnu.org>
 
        PR fortran/58007
diff --git a/gcc/testsuite/g++.dg/other/pr55650.C 
b/gcc/testsuite/g++.dg/other/pr55650.C
new file mode 100644
index 000000000000..fc52b19f5d30
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/pr55650.C
@@ -0,0 +1,21 @@
+// PR gcov-profile/55650
+// { dg-do link }
+// { dg-options "-O2 -fprofile-generate" }
+// { dg-additional-sources "pr55650.cc" }
+
+struct A
+{
+  virtual void foo ();
+};
+
+struct B : public A
+{
+  B ();
+  void foo () {}
+};
+
+inline A *
+bar ()
+{
+  return new B;
+}
diff --git a/gcc/testsuite/g++.dg/other/pr55650.cc 
b/gcc/testsuite/g++.dg/other/pr55650.cc
new file mode 100644
index 000000000000..70b41462b57e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/pr55650.cc
@@ -0,0 +1,4 @@
+int
+main ()
+{
+}
-- 
Markus

Reply via email to