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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:58:08+00:00 2026-05-25T00:58:08+00:00

A few days ago I saw that for ( ; ; ) results in

  • 0

A few days ago I saw that for ( ; ; ) results in an infinite loop. That made me wonder about two things.

  1. Is the empty statement ( ; ) no-op in assembler
  2. Why is it evaluated as “true” in the for example given above?
  • 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-25T00:58:08+00:00Added an answer on May 25, 2026 at 12:58 am

    Answering from a C perspective here:

    No, ; does not translate into a no-op instruction. No-op instructions (such as nop) are explicit assembly level instructions which tend to actually do something (in that they consume time, though not necessarily affect any stored state within the CPU).

    The for(;;) snippet is a for loop with defaults for each of the three sections. You can think of the ; in this case as not being an empty statement but a separator for the sections (a).

    • The first section (initialisation) has a default of “do nothing”.
    • The second section is a condition under which the loop will continue. Its default is to continue forever.
    • The third section, the steps to take before beginning a subsequent iteration, is also “do nothing”.

    I have, in the past, been guilty of the heinous crime of using things like:

    #define ever ;;
    #define forever for (;;)
    

    so that I could write my infinite loops as:

    for(ever) { ... }
    forever { ... }
    

    I wouldn’t do that nowadays of course.


    (a) A “true” empty statement along the lines of:

    if (condition) {
        a = b;
        ;
    }
    

    will also probably not translate to a no-op. More than likely it will not result in any code at all.

    Keep in mind this is based on fairly common behaviour. In terms of C, ; can generate any lower level code it wants as long as it doesn’t affect the “virtual machine” that is the C environment. It may, for example, increase a hidden line number variable and update coverage statistics if you have profiling enabled.

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

Sidebar

Related Questions

few days ago i asked about how to get all running processes in the
few days ago i read tutorial about GenericRepository and Unit Of Work patterns http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application
A few days ago I asked this question about jquery ajax function invoking action
so I asked here few days ago about C# and its principles. Now, if
few days ago I asked here about implementing USB. Now, If I may, would
A few days ago I asked a question that might be a little unclear.
A few days ago, I posted this question and this question asking about how
A few days ago I has asked a question on SO about helping me
A few days ago I asked a question about returning select fields from a
When I was writing C# code a few days ago I noticed that the

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.