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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:59:21+00:00 2026-05-27T16:59:21+00:00

Are there any general rules I can use for evaluating whether a modern compiler

  • 0

Are there any general rules I can use for evaluating whether a modern compiler will inline a function? What is the relative cost of an extra stack frame (I know it’s very small, but is there any way to generally quantify it – within an order of magnitude or so)?

I’m also particularly interested in:

  • Can a compiler inline methods defined in a cpp?
  • I know some compilers implement some optimizations even in debug (VS uses RVO in debug but not NRVO) – What’s the situation for inlining? I would imagine that it’s disabled so that we can see an expected call stack for debugging.

I’m currently trying to micro-optimize a memory tracking system, specifically ones that also apply without optimization enabled (in debug).

  • 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-27T16:59:22+00:00Added an answer on May 27, 2026 at 4:59 pm

    It’s easy to predict and hard to predict. Simple expressions, like:

    int a = b + (2 * c):
    int d = e + (2 * c);
    

    get optimized with the simplest optimizations (the (2 * c) “common subexpression” will only be computed once.

    In C/C++, methods declared inlined generally will be (though not always).

    Trickier are loop optimizations and the like. Eg,

    for (int i = 1; i < n; i++) {
        a = i + (2 * c);
    }
    

    the expression (2 * c) will usually get pulled out of the loop, in a compiler that does “global optimization”, but not in one that does only “local optimization”. And, of course, expressions can get much more complicated and convoluted.

    Change the body of the above loop to a = i * (2 * c);, and you progress to a slightly higher level of global optimization known as “loop induction”. A “smart” compiler will figure out to just add 2 * c (as precomputed) to a for each iteration through the loop, vs doing the (more expensive) multiply on each iteration.

    And that’s just scratching the surface.

    But I have no idea what the Visual Studio compilers are capable of.

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

Sidebar

Related Questions

In designing any desktop applications, are there any general rules on how much memory
I was wondering if there are any general guidelines for when to use regex
Are there any general rules on how to realiably locate OEPs (Original Entry Points)
I know this maybe quite subjective, but are there any general rules for situations
Are there any handy general items you put in your .procmailrc file?
Is there any easy/general way to clean an XML based data source prior to
Is there any way to check whether a file is locked without using a
Is there any query which can return me the number of revisions made to
Is there any difference between int on_exit(void (*function)(int , void *), void *arg); and
Possible Duplicate: Properties vs Methods Is there any rule or general best practice as

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.