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

  • Home
  • SEARCH
  • 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 1008633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:48:05+00:00 2026-05-16T08:48:05+00:00

Possible Duplicate: while (1) Vs. for (;;) Is there a speed difference? Hi, Which

  • 0

Possible Duplicate:
while (1) Vs. for (;;) Is there a speed difference?

Hi,

Which is better,faster and more optimized way to implement infinite loop – for(;;) or while(1)? and why?

  • 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-16T08:48:06+00:00Added an answer on May 16, 2026 at 8:48 am

    In any normal compiler, there should be absolutely no difference. For example, here’s what LLVM-clang generates (with the -O3 flag) for while (1) {}:

        .file   "test.c"
        .text
        .globl  main
        .align  16, 0x90
        .type   main,@function
    main:
        pushl   %ebp
        movl    %esp, %ebp
        .align  16, 0x90
    .LBB0_1:
        jmp .LBB0_1
    

    Note the jmp .LBB0_1 part, which is the actual infinite loop. For the for (;;) kind, it generates absolutely the same code.

    You can also try with other compilers for fun, but it’s best just stop worrying about it.


    OK, I just had to try with gcc as well:

        .file   "test.c"
        .text
    .globl main
        .type   main, @function
    main:
        pushl   %ebp
        movl    %esp, %ebp
    .L2:
        jmp .L2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 506k
  • Answers 506k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You will get a complaint from Mercurial and the push… May 16, 2026 at 3:51 pm
  • Editorial Team
    Editorial Team added an answer Use: WHERE xmlcolumn.value('(/path/to/tag)[1]', 'int') = @QueryValue Change the data type… May 16, 2026 at 3:51 pm
  • Editorial Team
    Editorial Team added an answer Actually, I see a workaround (pass not a string parameter,… May 16, 2026 at 3:51 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Possible Duplicate: Difference between declaring variables before or in loop? Is there any (or
Possible duplicate question: Is there a way to indefinitely pause a thread? In my
Possible Duplicate: Is there an attribute I can add to a class so it
Possible Duplicate: Reference - What does this symbol mean in PHP? Is there any
Possible Duplicate: Default value to a parameter while passing by reference in C++ Is
Possible Duplicate: How to avoid entering library's source files while debugging in Qt Creator
Possible Duplicate: What does a type followed by _t (underscore-t) represent? While typing in
Possible Duplicate: “Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given” error while
Possible Duplicate: Copy a linked list Hello stackoverflow! I am trying to learn more
Possible Duplicate: System.Random keeps on returning the same value I'm refactoring and expanding a

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.