Here's a rough block diagram of the behavior of gcov (and related software such as gcovr and lcov):

Figure: gcov data stream
When the compiler (GCC) generates object code and was asked to insert equipment for coverage / profiling, it performs two additional functions:
- The object code is for writing coverage metrics to a .gcda file after execution.
- A .gcno file is created that describes the structure of the object code.
The gcov utility then analyzes the .gcda and .gcno files to calculate coverage rates. For annotated source report, it also reads the source file.
Since it is the compiler that determines which part of the object code corresponds to a particular line, the report you showed is correct: this line does not exist. More precisely: no object code was created for these lines of source code. This is usually the expected behavior, since many lines of source code are only compile-time declarations.
In your case, you have a C ++ class with built-in functions (any function definitions in the class definition are implicitly built-in). The compiler does not need to generate code for built-in functions that are not used. This would be different if you use non-built-in functions, i.e. Declare functions in the header file and provide implementations in the .cpp file.
So what happened to the three executions of the closing brace? The compiler often needs to emit some code related to initializing and cleaning static objects. This code is not actually associated with a particular line and therefore appears as part of the last line in your compiler.
source share