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

  • Home
  • SEARCH
  • 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 6037463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:04:39+00:00 2026-05-23T06:04:39+00:00

MWE #include <iostream> struct Foo { Foo() { std::cout << Constructing Foo << this

  • 0

MWE

#include <iostream>

struct Foo {
  Foo() {
    std::cout << "Constructing Foo " << this << std::endl;
  }

  ~Foo() {
    std::cout << "Destructing Foo " << this << std::endl;
  }
};

Foo global_foo;

int main () {
  std::cout << "Entering and exiting main()" << std::endl;
  return 0;

}

The problem

Compile the above with options -fprofile-arcs -ftest-coverage, runn the program, and then run gcov. The program output clearly shows that Foo::Foo(), main(), and Foo::~Foo() are called, in that order. The gcov output shows that Foo::Foo() and main() are called, but not Foo::~Foo().

Root cause

The global objects are destroyed by a GNU internal exit handler (function registered with at_exit()). The final gcov stats are produced by another exit handler. The gcov exit handler is obviously called before the global destruction exit handler, so gcov doesn’t see the destructors being called.

Bug status

This is an old, old bug in gcov. Here’s the Bugzilla link: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7970. The bug still exists nine years later, at least in i686-apple-darwin10-g++-4.2.1.

The question

Is this an unresolvable bug in gcov, something I have to live with, or is it just something that happened to slip through the cracks (nine years old and utterly forgotten)? If the latter, how to fix it?

  • 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-23T06:04:40+00:00Added an answer on May 23, 2026 at 6:04 am

    First off, note that that bug report hasn’t been reconfirmed since 2005; you should probably add a note saying that you’re still seeing the bad behavior in g++-4.2.1. Even if no one acts on your message, it’s useful to have that information out there.

    Short term, if you want to go on using gcov you have to live with it. You might consider lcov instead, which gives you the ability to exclude specified lines from the coverage analysis. Fair warning: I’ve heard that it’s nice, but I’ve never used it myself.

    Medium term, add that response to the bug tracker! No guarantees, but perhaps that will generate enough interest for some kind soul to write you a patch.

    Long term, if no one is willing to patch it for you, you may be able to patch it yourself. gcc is not the friendliest codebase in the world, and getting your changes accepted can be an adventure, but if you really need this, you can make it happen.

    Best of luck.

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

Sidebar

Related Questions

I found a good way to check if a file exists and read the
I want to generate high-quality diagrams for a presentation. I’m using Python’s matplotlib to
given all the possible solutions to have a template system with GNU Emacs, what
During an assignment, I was asked to show that a hash table of size
I understand how to use Events according to Net Framework guidelines, but what are
Hi I have a question that: consider I have T(n) = m * n^2
Assume we have three arrays of length N which contain arbitrary numbers of type
I'm we're trying to figure out if there would be a way to convert

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.