Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7605195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:06:17+00:00 2026-05-31T00:06:17+00:00

I developed a simple example to test gcovr and gcov: #include <iostream> int main

  • 0

I developed a simple example to test gcovr and gcov:

#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;                                                                                                                                             
}   

And a script for coverage report generation:

#! /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      

I got coverage 80% using -b option and it point me on the last line in main block. It seems to me that it should be 100% for such scenario or not?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:06:18+00:00Added an answer on May 31, 2026 at 12:06 am

    This is an issue with gcov. If you look at the underlying gcov output [which the example driver is so courteous to leave for us as build-run/^#main.cpp.gcov], you see:

    […snip…]
            3:   21:    return 0;
    function _Z41__static_initialization_and_destruction_0ii called 3 returned 100% blocks executed 100%
            6:   22:}
    branch  0 taken 3 (fallthrough)
    branch  1 taken 0
    branch  2 taken 3 (fallthrough)
    branch  3 taken 0
    function _GLOBAL__I_main called 3 returned 100% blocks executed 100%
            3:   23:/*EOF*/
    call    0 returned 3
    

    I think what is being reported is branch coverage for the destructors of static members of objects in the iostream library. … while we try and filter out most of the gcov weirdness through gcovr, this is one of the cases that we cannot reliably ignore.

    Bill Hart
    John Siirola

    P.S. I encourage you to submit gcovr tickets on the gcovr Trac page: https://software.sandia.gov/trac/fast/newticket

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I developed one simple android application targeting the Mobiles with android 2.0 OS.I want
I have developed a simple mechanism for my mvc website to pull in html
I've developed a simple file browsing HTTP module which uses virtual paths (i.e. paths
I have developed a simple library in Ruby and need to use this in
I have developed a simple location aware iPhone application which is functionally working very
i developed a very simple vb.net application and i need a way for every
I've developed a very simple host and client which I wanted to use to
I've developed a very simple ASP.NET (jQuery) application. The RDBMS is MS Sql Server
I've developed an equation parser using a simple stack algorithm that will handle binary
I have a simple windows Service developed in VS.net 2008 and VB.net. When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.