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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:34:07+00:00 2026-06-16T11:34:07+00:00

In C99 6.2.5 P27 All pointers to structure types shall have the same representation

  • 0

In C99 6.2.5 P27

All pointers to structure types shall have the same representation and alignment requirements
as each other. All pointers to union types shall have the same representation and
alignment requirements as each other. Pointers to other types need not have the same
representation or alignment requirements.

What does this mean?

All pointers to structure types shall have the same representation and alignment requirements as each other.

And what is the reason for this exception?

Pointers to other types need not have the same representation or alignment requirements.

I’d appreciate an explanation with relevant examples.

  • 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-16T11:34:09+00:00Added an answer on June 16, 2026 at 11:34 am

    It means that you can store any pointer-to-structure value in any other pointer-to-structure variable, and in the process you create a valid pointer object, and you can recover the original pointer from the intermediate variable. By contrast, you are not allowed to use a pointer of a different category as an intermediate. For example:

    struct Foo * p = &x;   // x is a struct Foo
    struct Bar * q;
    
    memcpy(&q, &p, sizeof p);  // OK, it's allowed to read (but not dereference!) q
    memcpy(&p, &q, sizeof q);  // OK, p is now the same it was before
    
    union Zip * r;
    int       * s;
    
    // not allowed to do the same with (p, r) and (p, s)!
    

    The memcpys are OK because both p and q have the same size and alignment, because they are both pointers-to-structs. The same is true for two pointers-to-union, or for two pointers-to-int, but you cannot mix categories.

    Here’s another, very contrived, but valid example:

    struct Foo { int a; };
    
    int f(struct Bar * p)
    {
        return (struct Foo *)(p)->a;
    }
    
    int main()
    {
        Foo x = { 12 };
        return f((struct Bar *)(&x));
    }
    

    This program would not be valid if the function parameter of f were a pointer of a different category (say a pointer-to-union or pointer-to-int).

    The only pointer type that any object pointer can be converted to and back is void *. (So we could have made the parameter of f a void *. This is arguably the most common style. But it’s conceivable that making it a struct pointer is more efficient and thus preferable on some platforms.)

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

Sidebar

Related Questions

gcc 4.1.2 c99 I have the following enum's in this file ccsmd.h : enum
Before C99 programmers were obliged to define all arrays with fixed sizes that were
As per C99, there maybe padding bits in signed int or unsigned int representation
I have a c99 function that uses openmp, which works as expected. I also
What type for array index in C99 should be used? It have to work
The C99 standard defines the range of data types in the following manner: —
gcc 4.4.1 C99 I am creating a client server application. I have a Makefile
Background Unfortunately the current C++ standard lacks C99's exact-width types defined in the stdint
I'm wondering why C99 allows conversions between incompatible pointer types: void f(int* p) {
Are there any c compilers for ms-dos that support some C99 features? I have

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.