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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:56:05+00:00 2026-05-14T15:56:05+00:00

Is there a way to define using typedef integral/float type which implies no aliasng?

  • 0

Is there a way to define using typedef integral/float type which implies no aliasng?

something equivalent to (but primitive construct):

template < typename T >
struct restrict { T* __restrict data; };

as related question, is it possible to ask gcc what it determines alias/no alias of pointer is?

  • 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-14T15:56:05+00:00Added an answer on May 14, 2026 at 3:56 pm

    As noted in the comments, many newer C++ compilers do support the C99 implementation of the restrict type qualifier. Since restrict is not a reserved keyword in C++, the compilers generally use __restrict or __restrict__. Both GCC and Visual C++ document this nicely, with explicit references to C99.

    The C++ 1998 standard states that “The typedef specifier shall not … be combined in a decl-specifier-seq with any kind of specifier except a type-specifier.” Essentially, it must be a list of type-specifiers, which includes the two cv-qualifiers, const and volatile.

    C99 defines typedef similarly, except that its list of qualifiers includes restrict.

    It would seem reasonable to anticipate similar support in typedefs for the nonstandard __restrict… but you never know!

    A clever and easy way to test this is as follows:

    extern void link_fail();
    
    typedef int *__restrict restricted_int_p;
    
    void test(restricted_int_p a, restricted_int_p b) {
        *a = 1;
        *b = 2;
    
        if (*a == 2) link_fail();
    }
    

    This simply exploits the fact that if the unresolved link_fail symbol is found in the object file, the linker will throw an error. If the compiler is properly restricting the two arguments, then it should know the value of a, even after b is changed. Thus, it should strip the entire if block from the generated object file since it will never be run.

    Note that although GCC supported the restrict syntax since at least version 3.0, it really didn’t perform the proper optimizations until version 4.5.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer First of all you have problem with quotes in the… May 16, 2026 at 11:54 am
  • Editorial Team
    Editorial Team added an answer Have you checked the latest version of UC? The release… May 16, 2026 at 11:54 am
  • Editorial Team
    Editorial Team added an answer IQueryable's LINQ methods take Expression Trees, not normal delegates. Therefore,… May 16, 2026 at 11:54 am

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

I am building an automation system using Powershell and I would like to define
I have a very big constant array that is initialized at compile time. typedef
I am attempting to wrap some C code in Python using Pyrex. I've run
I am looking to define a template class whose template parameter will always be
I'm working on a code base in which we have several configurable types. One
I've written a collection of data structures and functions in C, some of which
I am trying to convert a macro in C to something that would work
I am using Excel interop in my VB.NET program. My problem is that I
The Size of pointer depends on the arch of the machine. So sizeof(int*)=sizeof(int) or
I want to make sure that a set of functions have the same signature

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.