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 8161431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:29:54+00:00 2026-06-06T18:29:54+00:00

I compiled the following program with gcc -fprofile-arcs -ftest-coverage test.c: int main() { int

  • 0

I compiled the following program with “gcc -fprofile-arcs -ftest-coverage test.c”:

int main() {
  int a = 1;
  int b = 1;
  a && b;
}

After running the program, an invocation of “gcov -bc test.c” reports that 50% of 4 branches were taken at least once. Why does gcov say the program has four branches, instead of two? After running the following program, gcov correctly reports that 50% of 2 branches were taken at least once:

int main() {
  int a = 1;
  if (a)
    a = 0;
  else
    a = 1;
}
  • 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-06-06T18:29:55+00:00Added an answer on June 6, 2026 at 6:29 pm

    Apparently gcov is considering a&&b to be the following:

    if(a) { // branch 1
        if(b) { // branch 2
            1; 
        } else { // branch 3
            0;
        }
    } else { // branch 4
        0;
    }
    

    Though I’m fairly certain the actual CPU instructions will translate to a single branch.

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

Sidebar

Related Questions

The following test.c program int main() { dummySum(1, 2); return 0; } int dummySum(int
I have the following program: ~/test> cat test.cc int main() { int i =
Hi I have the following program. When I compile on the terminal gcc main.c
I'm trying to compile the following program: #include<functional> #include<iostream> int main(int argc, char* argv[],
The following C++ program compiles and runs as expected: #include <stdio.h> int main(int argc,
Consider the following program, which is obviously buggy: #include <cstdio> double test(int n) {
I wrote the following program: #include<stdio.h> int main(void) { float f; printf(\nInput a floating-point
For the following program: int DivZero(int, int, int); int main() { try { cout
The following C program: #include <stdio.h> int main(void) { printf("%u %u %u\n",sizeof "",sizeof(""+0),sizeof(char *));
I've made a simple program and compiled it with GCC 4.4/4.5 as follows: int

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.