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

The Archive Base Latest Questions

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

Sorry if this sounds like an It compiles, so it must work! question, but

  • 0

Sorry if this sounds like an “It compiles, so it must work!” question, but I want to understand why something is happening (or not happening, as the case may be).

In Project Settings, I set Basic Runtime Checks to Both. The debugger informs me that:

Run-Time Check Failure #2 – Stack around the variable ‘beg’ was corrupted.

But if I set it to the default, which is none, the program runs and completes normally, throwing no exceptions and causing no errors.

My question is, can I safely ignore this (because MSVC++ could be somehow wrong) or is this a real problem? I don’t see how the program can continue successfully when the stack has been screwed up.


Edit:

The function that causes this error looks exactly like this:

int fun(list<int>::iterator&, const list<int>::iterator&);

int foo(list<int>& l) {
    list<int>::iterator beg = l.begin();
    list<int>::iterator end = l.end();
    return fun(beg, end);
}

fun increments and operates on beg and when it returns, beg == end, and when MSVC++ breaks, it points to the closing }.


Edit 2:

I have isolated the problem. In some situations, fun removes some elements from the list who owns the items it iterates. This is what causes the error.

  • 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-24T05:33:54+00:00Added an answer on May 24, 2026 at 5:33 am

    Your question isn’t answerable without code to reproduce the problem.

    But to give a vague answer to your general problem – If the compiler or debugger detected a problem, you probably have one.

    In C++, just because something “goes wrong” doesn’t mean your program will crash – it might keep running with completely unpredictable results. It may even complete with the results you desired. But just because it ran well on your system doesn’t give you any guarantee for other systems, compilers, times of day, or even for additional runs of the same program.

    This is called undefined behavior, and is caused by using the language incorrectly (but not in a way that causes a compile failure). A buffer overrun is only one of dozens of examples.

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

Sidebar

Related Questions

Sorry if this sounds like a really stupid question, but I need to make
Sorry if this question sounds a little silly, but I am not sure what
Sorry if this sounds like a really silly question. But I Googled the web
Sorry if this sounds like a newbie question, but the other day a Java
(Sorry if this sounds like a rant, but it's a real question and I'd
Ok sorry this might seem like a dumb question but I cannot figure this
This sounds like a relatively simple question, but I haven't been able to get
I'm sorry if this will sound like a dumb question but I just can't
Sorry if this sounds like a bit of a noobie question, i'm still relatively
I'm sorry if this sounds like a stupid question, because it seems to be

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.