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

Ticket #3919 (closed defect: invalid)

Opened 2 years ago

Last modified 9 months 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:

Description

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:  http://stackoverflow.com/questions/9475970/gcovr-branch-coverage-for-simple-case

Attachments

Change History

comment:1 Changed 16 months ago by wehart

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

comment:2 Changed 9 months 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.

View

Add a comment

Modify Ticket

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


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

 
Note: See TracTickets for help on using tickets.