https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98273
Bug ID: 98273
Summary: GCOV intermediate format is wrong when lambda
functions (or nested functions) are used
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
CC: marxin at gcc dot gnu.org
Target Milestone: ---
Consider the following example:
$ bat gcov-lambda.C
───────┬──────────────────────────────────────────────────────────────────────────────────────
│ File: gcov-lambda.C
───────┼──────────────────────────────────────────────────────────────────────────────────────
1 │ int main()
2 │ {
3 │ int i = 42;
4 │ {
5 │ auto f = [](){};
6 │ f();
7 │ }
8 │ ++i;
9 │ ++i;
10 │ ++i;
11 │ return 45 - i;
12 │ }
───────┴──────────────────────────────────────────────────────────────────────────────────────
we wrongly generate:
"lines": [
{
...
{
"branches": [],
"count": 1,
"function_name": "_ZZ4mainENKUlvE_clEv",
"line_number": 6,
"unexecuted_block": false
},
{
"branches": [],
"count": 1,
"function_name": "_ZZ4mainENKUlvE_clEv",
"line_number": 8,
"unexecuted_block": false
},
As seen line #8 is wrongly assigned to the lambda function, instead of the main
function.