[llvm-bugs] [Bug 51003] New: [llvm-cov] wrong coverage after executing exit(0) statement

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 7 00:14:15 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51003

            Bug ID: 51003
           Summary: [llvm-cov] wrong coverage after executing exit(0)
                    statement
           Product: Runtime Libraries
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: libprofile library
          Assignee: unassignedbugs at nondot.org
          Reporter: byone.heng at gmail.com
                CC: llvm-bugs at lists.llvm.org

$./clang -v                                                                     
clang version 12.0.0 (https://github.com/llvm/llvm-project.git
b6c8feb29fce39121884f7e08ec6eb0f58da3fb7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/x/project/llvm-project/build/install/bin/.
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

$cat test.c
const volatile long int true_var = 1;
volatile signed char false_var = 0;
extern void exit(int);
extern void abort(void);
int a[10];
int foo()
{
  exit (0);
  return 0;
}
int main()
{
  if (&a[foo()])
    abort ();
  return 0;
}

$gcc -O0 --coverage test.c;./a.out;gcov test;cat test.c.gcov

    1|       |/* { dg-do run } */
    2|       |
    3|       |const volatile long int true_var = 1;
    4|       |volatile signed char false_var = 0;
    5|       |
    6|       |extern void exit(int);
    7|       |extern void abort(void);
    8|       |int a[10];
    9|       |int foo()
   10|      1|{
   11|      1|  exit (0);
   12|      0|  return 0;
   13|      1|}
   14|       |int main()
   15|      1|{
   16|      1|  if (&a[foo()])
   17|      0|    abort ();
   18|      1|  return 0;
   19|      1|}

>From my perspective, the function exit(0) in line 11 has been executed, so the
program should terminate, line 18 should not be executed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210707/41706cb1/attachment.html>


More information about the llvm-bugs mailing list