https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86109

            Bug ID: 86109
           Summary: [GCOV] gcov reports lines in lambdas as not executable
           Product: gcc
           Version: 8.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jasminekahuja at yahoo dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

gcov doesn't report lines in lambdas as executable, so it won't properly report
coverage for lambdas.

$ /xyz/toolchain13/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/xyz/toolchain13/bin/g++
COLLECT_LTO_WRAPPER=/xyz/toolchain13/libexec/gcc/x86_64-pc-linux-gnu/8.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc_8_1_0/configure --prefix=/xyz/toolchain13
--enable-languages=c,c++ --enable-lto --disable-plugin --program-suffix=-8.1.0
--disable-multilib --disable-shared
Thread model: posix
gcc version 8.1.0 (GCC) 

$ /xyz/toolchain13/bin/gcov -v
gcov (GCC) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.

$ cat hello.cpp 
int main()
{
    auto partially_uncovered_lambda = [](int i) {
        if (i > 10)
            return 0;
        return 1;
    };
    partially_uncovered_lambda(20);
}

$ /xyz/toolchain13/bin/g++ -w -fprofile-arcs -ftest-coverage -std=c++17
hello.cpp; ./a.out; /xyz/toolchain13/bin/gcov hello.cpp; cat hello.cpp.gcov
File 'hello.cpp'
Lines executed:100.00% of 3
Creating 'hello.cpp.gcov'

        -:    0:Source:hello.cpp
        -:    0:Graph:hello.gcno
        -:    0:Data:hello.gcda
        -:    0:Runs:1
        -:    0:Programs:1
        1:    1:int main()
        -:    2:{
        -:    3:    auto partially_uncovered_lambda = [](int i) {
        -:    4:        if (i > 10)
        -:    5:            return 0;
        -:    6:        return 1;
        -:    7:    };
        1:    8:    partially_uncovered_lambda(20);
        1:    9:}

Would expect to see line 6 show up as uncovered.

Reply via email to