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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:55:39+00:00 2026-05-18T03:55:39+00:00

I could have also phrased this as What constitutes observable behavior? The C++ Standard

  • 0

I could have also phrased this as What constitutes observable behavior?

The C++ Standard talks a lot about observable behavior, but I am not really sure if program termination is part of observable behavior.

That is, given a program such as:

int main() {
  for(;;) {}
  return 0;
}

is a conforming implementation allowed to ever terminate this program?

  • 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-18T03:55:40+00:00Added an answer on May 18, 2026 at 3:55 am

    Yes it is legal for the compile to generate an empty main body for the above code (thus terminating almost immediately).

    The C++0x FCD says 6.5 says (pay special attention to the note):

    A loop that, outside of the for-init-statement in the case of a for statement,
    * makes no calls to library I/O functions, and
    * does not access or modify volatile objects, and
    * performs no synchronization operations (1.10) or atomic operations (Clause 29)

    may be assumed by the implementation to terminate. [ Note: This is intended to allow compiler transformations, such as removal of empty loops, even when termination cannot be proven. — end note ]

    So the compiler can assume that your for loop will terminate and since the body is empty it can optimize it away altogether.


    The quotation from the draft was copied from this question and verified against my copy.

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

Sidebar

Related Questions

I have strings like this: Car is blue String could also be like this:
Okay, I kinda asked this question already, but noticed that i might have not
It looks like a problem which could have simple solution, but I haven't found
I'm new to ASP.NET MVC so this could have an obvious answer. Right now
I want to have a dictionary of functions. With this dictionary, I could have
Ok, so maybe my search syntax is wrong here, this could have very well
I think the title for this question is probably wrong, but I'm not sure
I have a csv file like this name,sex,age venu,m,16 test,,22 [EDIT] name could have
I am not sure how to phrase this question, but I am trying to
I have a high level question about how to architect this app in django.

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.