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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:52:53+00:00 2026-05-29T05:52:53+00:00

Question is in bold below : This works fine: void process_batch( string_vector & v

  • 0

Question is in bold below :

This works fine:

void process_batch( 
  string_vector & v
) 
{

  training_entry te;
  entry_vector sv; 
  assert(sv.size() == 0);
...
}

However, this causes the assert to fail :

   void process_batch( 
      string_vector & v
    ) 
    {
      entry_vector sv; 
      training_entry te;
      assert(sv.size() == 0);
      ...
   }

Now I know this issue isn’t shrink wrapped, so I’ll restrict my question to this: what conditions could cause such a problem ? Specifically: variable initialization getting damaged dependant on appearance order in the stack frame. There are no malloc’s or free’s in my code, and no unsafe functions like strcpy, memcpy etc… it’s modern c++. Compilers used: gcc and clang.

For brevity here are the type’s

struct line_string
{
  boost::uint32_t line_no;
  std::string     line;
};

typedef  std::vector<boost::uint32_t> line_vector;
typedef std::vector<line_vector> entry_vector;
typedef std::vector<line_string> string_vector;

struct training_body
{
  boost::uint32_t url_id;
  bool relevant;
};

struct training_entry
{
  boost::uint32_t session_id;
  boost::uint32_t region_id;
  std::vector< training_body> urls;
};

p.s., I am in no way saying that there is a issue in the compiler, it’s probably my code. But since I am templatizing some code I wrote a long time ago, the issue has me completely stumped, I don’t know where to look to find the problem.

edit

followed nim’s suggestion and went through the following loop

  1. shrink wrap the code to what I have shown here, compile and test, no problem.
  2. #if 0 #endif to shrink wrap the main program.
  3. remove headers till it compiles in shrink wrapped form.
  4. remove library links till compiles in shrink wrapped form.

Solution: removing link to protocol buffers gets rid of the problem

  • 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-29T05:52:53+00:00Added an answer on May 29, 2026 at 5:52 am

    The usual case for this when one of the created objects writes beyond
    its end in the constructor. And the most frequent reason this happens
    in code I’ve seen is that object files have been compiled with different
    versions of the header; e.g. at some point in time, you added (or
    removed) a data member of one of the classes, and didn’t recompile all
    of the files which use it.

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

Sidebar

Related Questions

Please do not mark it as a dupe of this question just yet: Bold
I have the below question as well as this time i have done some
Bear with me while I explain my question. Skip down to the bold heading
This is probably (hopefully) a pretty simple question, but I can't seem to get
This question is long winded because I have been updating the question over a
My question (which will follow after this, sorry about the long intro, the question
This question is inspired by this recent question and other situations I've encountered in
I need a small FAQ page with Question in bold font and answer in
I know this sounds like a really obvious question, but it's proving harder to
I submitted another version of this question and a sample program before: How do

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.