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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:52:37+00:00 2026-05-25T12:52:37+00:00

Having recently read that the main reason why fortran is faster than c/c++ in

  • 0

Having recently read that the main reason why fortran is faster than c/c++ in numerical computations is because there is no pointer aliasing.

Apparently, using restrict or __restrict__ keywords allows on a case by case basis to indicate the absence of pointer aliasing for a given memory element.

The icc compiler apparently has an option -fno-alias which allows one to globally assume that no aliasing is present. On gcc there is -fno-strict-aliasing, which applies only to a subset of all the aliasing situations.

Is there an option present in gcc, or are there some cases where no aliasing is assumed, when using certain optimization flags?

  • 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-25T12:52:37+00:00Added an answer on May 25, 2026 at 12:52 pm

    GCC has the option -fstrict-aliasing which enables aliasing optimizations globally and expects you to ensure that nothing gets illegally aliased. This optimization is enabled for -O2 and -O3 I believe.

    C++ has well defined aliasing rules, though, and standard-compliant code will not conflict with strict aliasing. In particular this means you’re not allowed to access one variable through a pointer to a different type:

    float f;
    int * p = reinterpret_cast<int*>(&f);  // uh-oh
    *p = 0x3FF00000;                       // breaks strict aliasing
    

    The crucial exception to this rule is that you can always access any variable through a pointer to char. (This is necessary for serializing through IO operations.)

    The aliasing rules do not help the compiler to know whether any pointers of the same type alias each other. Consider this:

    void add(float * a, float * b, float * c) { *c = *a + *b; }
    

    Here the compiler cannot know whether c points to different memory than a or b and has to be careful. I think this is where restrict makes a difference, essentially by promising that float * restrict c means that nobody aliases c.

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

Sidebar

Related Questions

Recently I was having some issues with a singelton class that was lazy initializing
I just recently read about Mocking objects for unit testing and currently I'm having
Having read up recently on yahoo's web optimisation tips and using YSlow I've implemented
A have a Perl cron job that recently started having its HTTPS connections start
I recently read these notes about SEO which say that you loose Google juice
Having recently read up a on Objective-C it strikes me as a fairly neat
I recently upgraded to SQL Developer 3.0.04 because I was having great trouble with
I have started working with Hadoop recently. There is table named Checkout that I
Having recently learned of the DebuggerDisplay attribute, I've found it quite useful. However, one
Having recently discovered design patterns, and having acquired the excellent Head First Design Patterns

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.