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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:23:27+00:00 2026-06-15T20:23:27+00:00

gcov complains about one of my algorithms: File ‘Algorithm.h’ Lines executed:95.00% of 20 Algorithm.h:creating

  • 0

gcov complains about one of my algorithms:

File 'Algorithm.h'
Lines executed:95.00% of 20
Algorithm.h:creating 'Algorithm.h.gcov'

   17:   25:inline std::vector<std::string> starts_with(const std::vector<std::string>& input, const std::string& startsWith)
    -:   26:{
   17:   27:    std::vector<std::string> output;
   17:   28:    std::remove_copy_if(input.begin(), input.end(), std::back_inserter(output), !boost::bind(&boost::starts_with<std::string,std::string>, _1, startsWith));
#####:   29:    return output;
    -:   30:}

My test looks like this, and it passes:

TEST (TestAlgorithm, starts_with)
{
    std::vector<std::string> input = boost::assign::list_of("1")("2")("22")("33")("222");
    EXPECT_TRUE(starts_with(input,"22") == boost::assign::list_of("22")("222"));
}

What might the problem be? I’m not using optimization.

UPDATE:

My CMakeList.txt contains:

if(CMAKE_COMPILER_IS_GNUCXX)
    set(CMAKE_CXX_FLAGS "-O0")        ## Optimize
endif()
  • 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-15T20:23:29+00:00Added an answer on June 15, 2026 at 8:23 pm

    Try using the -fno-elide-constructors switch in g++

    From The Definitive Guide to GCC:

    -fno-elide-constructors: This option when compiling C++ options causes GCC not to omit creating temporary objects when initializing objects
    of the same type, as permitted by the C++ standard. Specifying this
    option causes GCC to explicitly call the copy constructor in all
    cases.

    Some discussions here:
    How can I get more accurate results from gcov?
    and here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076

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

Sidebar

Related Questions

All the GNU gcov manual online at http://gcc.gnu.org/onlinedocs/gcc/Invoking-Gcov.html#Invoking-Gcov says about gcov -f option is:
I want to show the gcov index.html result file in Jenkins. I tried with
Is it possible to exclude certain functions or lines of code from the gcov
I am attempting to profile (as in gcov style profiling) my unit tests for
Can anyone tell me what the gcov message Merge mismatch for summaries means? I
I have large project to analyse. How to use gcov or lcov for it.
Is it possible to use callgrind to produce the output like one given by
I'm running gcov/gcc 4.1.2 on RHEL. When I want to specify a directory for
Is it possible to use gcov for coverage testing of multi-threaded applications? I've set
I measure coverage for my code using gcov library and I would like to

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.