Debian Codegraph @

gcc/testsuite/g++.dg/gcov/gcov-23.C

raw
1 /* { dg-options "-fpath-coverage --coverage" } */
2 /* { dg-do run { target native } } */
3
4 #include "gcov-23-1.h"
5 #include "gcov-23-2.h"
6
7 /* This tests a very specific interaction between destructors of static objects
8 and gcov's inlining aware printing of prime paths. The source of the
9 problem is that gcc will reuse the compiler generated destructor gimple stmt
10 from the first static-object destructor, and its location will be recorded
11 in the .gcno file. This would lead to an empty block.locations vector since
12 the stmt is not anchored to a source line (being generated and all), but the
13 block itself would be originating in a different file.
14
15 Without properly guarding the block.loc.lines access this code caused a
16 segfault in gcov. The class needed a non-trivial member or otherwise
17 non-trivial constructor to emit approximately
18
19 __cxxabiv1::__cxa_atexit (__dt_comp , &self, &__dso_handle);
20
21 Triggering the failure needed the path to also be printed, so it is
22 important to request both covered and uncovered paths. */
23
24 int main ()
25 {
26 fst::instance().data = "foo";
27 snd::instance().data = "bar";
28 }
29
30 /* { dg-final { run-gcov { --prime-paths-source=both --prime-paths-lines=both gcov-23.C } } } */