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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:54:54+00:00 2026-06-07T08:54:54+00:00

In C, does usage of a pointer cancel the register property of the associated

  • 0

In C, does usage of a pointer cancel the “register” property of the associated variable?

#include<stdio.h>
#include<stdlib.h>
int main()
{
    register int clk=0;    //maybe register maybe not
    int *adr=&clk;         //not a register now? i have its address
    *adr=1;  //if i use this 1000000 times, does it exist in L1 at least?
    printf("%d",clk);
    return 0;

}

Gives compiler error “can’t take address of register variable” but it is not register %100. it is only a chance.

Is this the slowest loop?

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *p;
    int i=0;
    p=&i;
for(*p=0;(*p)<100;(*p)++)
{
    //do nothing
}
    printf("%d ",i);
    return 0;

}

If I make nearly all variables pointer-style and only three variables only primitive type with “register” keyword, does compiler make those three variables “really register” with a higher chance?

OK. Problem solved. I learned some assembly and found out that this depends on optimization level and also variable’s volatility. Using __asm{} makes sure it computes in a register.
Thanks.

  • 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-07T08:54:56+00:00Added an answer on June 7, 2026 at 8:54 am

    In C it’s illegal to apply & to a variable declared with the register specifier.

    6.7.1

    The implementation may treat any register declaration simply as an
    auto declaration. However, whether or not addressable storage is
    actually used, the address of any part of an object declared with
    storage-class specifier register cannot be computed, either
    explicitly (by use of the unary & operator as discussed in
    6.5.3.2) or implicitly (by converting an array name to a pointer as discussed in
    6.3.2.1).

    And 6.5.3.2:

    The operand of the unary & operator shall be either a function
    designator, the result of a [] or unary * operator, or an lvalue that
    designates an object that is not a bit-field and is not declared with
    the register storage-class specifier
    .

    As for C++, if you use & with a register, it cancels its meaning:

    ANSI C does not allow for taking the address of a register object;
    this restriction does not apply to C++. However, if the address-of
    operator (&) is used on an object, the compiler must put the object in
    a location for which an address can be represented
    . In practice, this
    means in memory instead of in a register.

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

Sidebar

Related Questions

Does any one know what is the exact usage of xmlns in HTML, XML
Does the android compatibility package return to default fragment usage if running 3.0+ or
What does that mean? Getting this in the console during usage of my app
Google's heavy usage of Python, is it just a matter of taste or does
I have used valgrinds massif tool to monitor memory usage in the past. Does
In C#, does setting a field as readonly reduce memory usage? i.e. DBRepository _db
What does it exactly mean to have a 350% cpu usage (by a process)
Follow-up question to [Does casting to a pointer to a template instantiate that template?]
Does anyone know if there is a way to generate different code in the
Does COUNT(*) have any significant impact for MySQL performance if query already has GROUP

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.