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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:46:27+00:00 2026-06-15T03:46:27+00:00

I am compiling flops via a loop with simple operations like such: for (i

  • 0

I am compiling flops via a loop with simple operations like such:

for (i = beginvar; i < endvar; i++) {
    for (j = beginvar; j < endvar; j++) {   
        num1 = ((num1 + num2) / num1);
    }
}

I never do anything with num1, however, and so the compiler is skipping over it and this loop takes 0 ms no matter how large beginvar and endvar are.

My question is, how can I force the compiler to execute the nested loop?

I’ve tried declaring num1 as volatile, but this does fewer optimizations than I want. I want the compiler to optimize, but I want it to execute this loop as well.

I also would not like to print anything to the terminal

  • 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-06-15T03:46:28+00:00Added an answer on June 15, 2026 at 3:46 am

    Use the value of num1 after the loop for something, so that the compiler cannot trivially eliminate it.

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

Sidebar

Related Questions

When compiling a c file that uses old style function definition like int foo(a)
After compiling a simple C++ project using Visual Studio 2008 on vista, everything runs
When compiling some code, I get an error like: endpointer.h:88:24: error: expected ‘)’ before
Compiling on linux using gcc. I would like to convert this to hex. 10
Compiling this simple function with MSVC2008, in Debug mode: int __cdecl sum(int a, int
When compiling, I always set it for Any CPU. However there are some customers
When compiling my code with the GNU C++ compiler I get something like bla.cxx:
Compiling my last build in Release mode i get some errors like : passing
compiling with gcc C99 I have been using enums for a while now. However,
Compiling a kernel module on 32-Bit Linux kernel results in __udivdi3 [mymodule.ko] undefined! __umoddi3

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.