Comments you submit will be routed for moderation. If you have an account, please log in first.

Ticket #3919 (closed defect: invalid)

Opened 6 years ago

Last modified 5 years ago

100% branch coverage can not be achieved with static objects usage in C++

Reported by: rkudiyarov@… Owned by: jdsiiro
Priority: normal Milestone:
Component: gcovr Version:
Keywords: Cc:


There is a tiny example code and script for compiling and running gcovr:

#include <iostream>                                                                                                                                       

int main (int argc, const char * argv[])                                                                                                                  
    std::cout << argc << std::endl;                                                                                                                       

    if(argc == 1)                                                                                                                                         
        int y = 1;                                                                                                                                        
        std::cout << "Argc > 1" << std::endl;                                                                                                             
    if(argc == 2) std::cout << "Argc > 2" << std::endl;                                                                                                   
    if(argc == 3)                                                                                                                                         
        std::cout << "Argc > 3" << std::endl;                                                                                                             

    int i = 34;                                                                                                                                           
    i = i * i;                                                                                                                                            

    return 0;                                                                                                                                             
#! /bin/bash                                                                                                                                              

rm -rf build-run                                                                                                                                          
mkdir build-run                                                                                                                                           
cd build-run                                                                                                                                              

g++ -O6 -DDEBUG=0 --coverage -ftest-coverage -fprofile-arcs -c -o main.o ../main.cpp                                                                      

g++ -O6 -DDEBUG=0 --coverage -fprofile-arcs -ftest-coverage -lgcov -o coverage ./main.o                                                                   

./coverage > out                                                                                                                                          
./coverage --help > out                                                                                                                                   
./coverage --help --out > out                                                                                                                             

gcovr -v -kpbu -r .. -o ../branch-report.txt                                                                                                              
gcovr -v -kpu -r .. -o ../report.txt 

If I do something wrong please answer here:


Change History

comment:1 Changed 5 years ago by wehart

  • Owner changed from wehart to jdsiiro
  • Component changed from EXACT to gcovr

comment:2 Changed 5 years ago by jdsiiro

  • Status changed from new to closed
  • Resolution set to invalid

This is an artifact of GCOV. gcovr is correctly tabulating and reporting the data generated by gcov.


Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.