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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:32:58+00:00 2026-05-23T12:32:58+00:00

I took a look at the draft C++0x standard, and as far as I

  • 0

I took a look at the draft C++0x standard, and as far as I can tell there is nothing about stack overflow in there. Searching for “stack overflow” yields no results, and searching for “stack” I’ve only gotten references to stack unwinding and std::stack. Does that mean that there cannot be a conforming implementation of the C++ standard, since there is no mechanism allowed for handling the error when memory is exhausted by a local object such as a huge local array?

The answers to this question indicate that at least the C standard does not mention stack overflow.

To make the question concrete, consider this program

// Program A
int identity(int a) {
  if (a == 0)
    return 0;
  char hugeArray[1024 * 1024 * 1024]; // 1 GB
  return identity(a - 1) + 1;
}
int main() {
  return f(1024 * 1024 * 1024);
}

and this program

// program B
int main() {
  return 1024 * 1024 * 1024;
}

I think the C++ standard does not allow any C++ implementation to do something observably different on these two programs. In reality program A won’t run on any modern machine as it is allocating an exabyte of memory on the stack (imagine the function actually used the huge array so the compiler can’t silently remove it to no ill effect). Does the C++ standard allow program A to fail?

Edit: The question is not whether the standard should define what happens on stack overflow, the question is what it says, if anything.

  • 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-23T12:32:59+00:00Added an answer on May 23, 2026 at 12:32 pm

    I’m not sure if this is what you’re looking for, but in Appendix B of the C++03 ISO standard there’s the following notice:

    1. Because computers are finite, C++ implementations are inevitably limited in the size of the programs they
      can successfully process. Every implementation shall document those limitations where known. This documentation may cite fixed limits where they exist, say how to compute variable limits as a function of
      available resources
      , or say that fixed limits do not exist or are unknown.
    2. The limits may constrain quantities that include those described below or others.

    (My emphasis) I take this to mean it is perfectly legal for the compiler to allow one of those functions to work while failing another, provided that the compiler states what limitations are in place and how they are computed from the resources the system has available.

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

Sidebar

Related Questions

I took a look about this problem within the list of question but nothing
there are many related questions/answers about that in SO. I took a look to
I took a look at some questions here at stack overflow like this &
Just wondering if there is a Python MTA . I took a look at
I just took a look at wordpad. There is a ribbon button called insert
I'm searching for a Python full text search engine. I took a look at
I know there's a lot of questions about ie7 z-index issues, I took a
Anybody know how this can be done? I took a look at cx_Freeze, but
I took a look at this answer and it goes in part to solving
I took a look in the developer's console and saw for the first time

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.