re PR gcov-profile/20815 (-fprofile-use barfs with "coverage mismatch for function...
authorJan Hubicka <jh@suse.cz>
Thu, 6 Apr 2006 20:33:21 +0000 (22:33 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Thu, 6 Apr 2006 20:33:21 +0000 (20:33 +0000)
PR profile/20815
PR profile/26399
* coverage.c (coverage_checksum_string): Reorganize loop to not read
after buffer.
* g++.dg/bprob/g++-bprob-2.C: New testcase.

From-SVN: r112738

gcc/ChangeLog
gcc/coverage.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/bprob/g++-bprob-2.C [new file with mode: 0644]

index 6391dd42546b5ba4bfb678e6f15d0c9dc018f8c3..6ee11b544c3569c8ef0cb16f78fa34e04a08843f 100644 (file)
@@ -1,3 +1,10 @@
+2006-04-06  Jan Hubicka  <jh@suse.cz>
+
+       PR profile/20815
+       PR profile/26399
+       * coverage.c (coverage_checksum_string): Reorganize loop to not read
+       after buffer.
+
 2006-04-06  Mike Stump  <mrs@apple.com>
 
        * builtins.c (expand_builtin_longjmp):Use #ifdef instead of #if
index 0ba0c110cbb3abc3ee0c83f1e2f722ee3d7679db..9d66e9e05895a1482aaed2fdd2ac4f6ea80694c0 100644 (file)
@@ -457,30 +457,31 @@ coverage_checksum_string (unsigned chksum, const char *string)
        to be no better chance then walk all possible offsets looking
        for magicnuber.  */
       if (offset)
-        for (;string[offset]; offset++)
-        for (i = i + offset; string[i]; i++)
-          if (string[i]=='_')
-            {
-              int y;
-
-              for (y = 1; y < 9; y++)
-                if (!(string[i + y] >= '0' && string[i + y] <= '9')
-                    && !(string[i + y] >= 'A' && string[i + y] <= 'F'))
-                  break;
-              if (y != 9 || string[i + 9] != '_')
-                continue;
-              for (y = 10; y < 18; y++)
-                if (!(string[i + y] >= '0' && string[i + y] <= '9')
-                    && !(string[i + y] >= 'A' && string[i + y] <= 'F'))
-                  break;
-              if (y != 18)
-                continue;
-              if (!dup)
-                string = dup = xstrdup (string);
-              for (y = 10; y < 18; y++)
-                dup[i + y] = '0';
-            }
-        break;
+       {
+         for (i = i + offset; string[i]; i++)
+           if (string[i]=='_')
+             {
+               int y;
+
+               for (y = 1; y < 9; y++)
+                 if (!(string[i + y] >= '0' && string[i + y] <= '9')
+                     && !(string[i + y] >= 'A' && string[i + y] <= 'F'))
+                   break;
+               if (y != 9 || string[i + 9] != '_')
+                 continue;
+               for (y = 10; y < 18; y++)
+                 if (!(string[i + y] >= '0' && string[i + y] <= '9')
+                     && !(string[i + y] >= 'A' && string[i + y] <= 'F'))
+                   break;
+               if (y != 18)
+                 continue;
+               if (!dup)
+                 string = dup = xstrdup (string);
+               for (y = 10; y < 18; y++)
+                 dup[i + y] = '0';
+             }
+         break;
+       }
     }
 
   chksum = crc32_string (chksum, string);
index 814f957662741504f143ced09e56f435cbfd3176..41398327f3d6dbecdc1c0405b1d4fdc04f11c14f 100644 (file)
@@ -1,3 +1,8 @@
+2006-04-06  Jan Hubicka  <jh@suse.cz>
+
+       PR profile/26399
+       * g++.dg/bprob/g++-bprob-2.C: New testcase.
+
 2006-04-06  Roger Sayle  <roger@eyesopen.com>
 
        * g++.dg/conversion/nullptr1.C: New test case.
diff --git a/gcc/testsuite/g++.dg/bprob/g++-bprob-2.C b/gcc/testsuite/g++.dg/bprob/g++-bprob-2.C
new file mode 100644 (file)
index 0000000..23577d4
--- /dev/null
@@ -0,0 +1,15 @@
+namespace {
+
+int calc(int j)
+{
+  if (j==0) return 0;
+  return calc(j-1)*j % 17;
+}
+
+}
+
+int main(void)
+{
+  return calc(25);
+}
+