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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:11:09+00:00 2026-05-25T11:11:09+00:00

In ISO/IEC 9899:TC2, the standard says following 6.3.2.3 Pointers A pointer to an object

  • 0

In ISO/IEC 9899:TC2, the standard says following

6.3.2.3 Pointers

  1. A pointer to an object or incomplete type may be converted to a pointer to a different
    object or incomplete type. If the resulting pointer is not correctly aligned for the pointed-to type, the behavior is undefined. Otherwise, when converted back again, the result shall compare equal to the original pointer. When a pointer to an object is converted to a pointer to a character type, the result points to the lowest addressed byte of
    the object. Successive increments of the result, up to the size of the object, yield pointers to the remaining bytes of the object.

So, it is not clear from the standard that a pointer of one type can be casted to pointer of another type.

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

    Strict aliasing rule is defined somewhere else. This is the wording:

    C (ISO/IEC 9899:1999 6.5/7):

    An object shall have its stored value accessed only by an lvalue
    expression that has one of the following types:

    • a type compatible with the effective type of the object,
    • a qualified version of a type compatible with the effective type of
      the object,
    • a type that is the signed or unsigned type corresponding to the
      effective type of the object,
    • a type that is the signed or unsigned type corresponding to a
      qualified version of the effective type of the object,
    • an aggregate or union type that includes one of the aforementioned
      types among its members (including, recursively, a member of a
      subaggregate or contained union), or
    • a character type.

    C++ (ISO/IEC 14882:2011 3.10 [basicl.lval] / 15):

    If a program attempts to access the stored value of an object through
    an lvalue of other than one of the following types the behavior is
    undefined:

    • the dynamic type of the object,
    • a cv-qualified version of the dynamic type of the object,
    • a type similar (as defined in 4.4) to the dynamic type of the object,
    • a type that is the signed or unsigned type corresponding to the
      dynamic type of the object,
    • a type that is the signed or unsigned type corresponding to a
      cv-qualified version of the dynamic type of the object,
    • an aggregate or union type that includes one of the aforementioned
      types among its elements or non-static data members (including,
      recursively, an element or non-static data member of a subaggregate
      or contained union),
    • a type that is a (possibly cv-qualified) base class type of the
      dynamic type of the object,
    • a char or unsigned char type.

    The C standard doesn’t prohibit you from casting the pointer to an unrelated type, provided there are no allignment problems. However, due to the strict aliasing rule, you basically can’t dereference a pointer obtained from such a cast. So the only useful thing to do with such “invalid” pointer is to cast it back to the correct type (or a compatible type).

    It’s mostly the same in C++ with reinterpret_cast (5.2.10 [expr.reinterpret.cast] / 7):

    An object pointer can be explicitly converted to an object pointer of a different type. When a prvalue v of type “pointer to T1” is converted to the type “pointer to cv T2”, the result is static_cast<cv T2*>(static_cast<cv void*>(v)) if both T1 and T2 are standard-layout types (3.9) and the alignment requirements of T2 are no stricter than those of T1, or if either type is void. Converting a prvalue of type “pointer to T1” to the type “pointer to T2” (where T1 and T2 are object types and where the alignment requirements of T2 are no stricter than those of T1) and back to its original type yields the original pointer value. The result of any other such pointer conversion is unspecified.

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

Sidebar

Related Questions

The C standard (ISO/IEC 9899:2011 or 9899:1999) defines a type ptrdiff_t in <stddef.h> .
ISO/IEC 9899:TC2 (i.e. the C99 standard), §7.20.3 states: If the size of the space
The C standard states: ISO/IEC 9899:1999, 6.2.5.15 (p. 49) The three types char, signed
The ISO C Standard (ISO/IEC 9899) and the ISO C++ Standard (ISO/IEC 14882) are
Why are there different PDF versions of the ISO/IEC 14882:2011 standard (C++11), which cost
The C++ standard (ISO/IEC 14882:03) states the following ( 2.11 / 2 ): Furthermore,
I was just reading ISO/IEC 9899:201x Committee Draft — April 12, 2011 in which
Does anyone know the ISO standard that covers .NET 3.5? I found ISO/IEC 23270:2006,
From the C++ standard (ISO/IEC 14882:2003(E)), §12.5.4, about overloading operator delete : If a
To begin with, I know about C++ Standard (ISO/IEC 14882:2003): Section 11.5, Paragraph 1

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.