• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
          • Syntax-for-tools
          • Atc
          • Language
            • Abstract-syntax
            • Integer-ranges
            • Implementation-environments
            • Dynamic-semantics
            • Static-semantics
            • Grammar
            • Integer-formats
            • Types
            • Portable-ascii-identifiers
            • Values
              • Pointer
                • Pointer-case
                • Pointer-fix
                • Pointer-equiv
                • Pointer-valid
                • Pointerp
                • Pointer-null
                • Pointer-dangling
                • Pointer-kind
              • Member-types-of-member-values
              • Member-value-list->value-list
              • Member-value-list->name-list
              • Expr-value
              • Type-list-of-value-list
              • Type-of-value
              • Value-option
              • Init-value
              • Value-result
              • Type-of-value-option
              • Value-list-result
              • Member-value-list-result
              • Init-value-result
              • Expr-value-result
              • Value-option-result
              • Signed/unsigned-byte-p-of-integer-values
              • Member-type-of-member-value
              • Bounds-of-integer-values
              • Value-promoted-arithmeticp
              • Init-type-of-init-value
              • Value-unsigned-integerp
              • Value-signed-integerp
              • Value-integerp
              • Value-arithmeticp
              • Value-scalarp
              • Value-realp
              • Values/membervalues
            • Integer-operations
            • Computation-states
            • Object-designators
            • Operations
            • Errors
            • Tag-environments
            • Function-environments
            • Character-sets
            • Flexible-array-member-removal
            • Arithmetic-operations
            • Pointer-operations
            • Bytes
            • Keywords
            • Real-operations
            • Array-operations
            • Scalar-operations
            • Structure-operations
          • Representation
          • Transformation-tools
          • Insertion-sort
          • Pack
        • Bv
        • Imp-language
        • Event-macros
        • Java
        • Bitcoin
        • Ethereum
        • Yul
        • Zcash
        • ACL2-programming-language
        • Prime-fields
        • Json
        • Syntheto
        • File-io-light
        • Cryptography
        • Number-theory
        • Lists-light
        • Axe
        • Builtins
        • Solidity
        • Helpers
        • Htclient
        • Typed-lists-light
        • Arithmetic-light
      • X86isa
      • Axe
      • Execloader
    • Math
    • Testing-utilities
  • Values

Pointer

Fixtype of pointers.

This is a tagged union type, introduced by fty::deftagsum.

Member Tags → Types
:null → pointer-null
:dangling → pointer-dangling
:valid → pointer-valid

Pointers are mentioned in several places in [C17], but there seems to be no specific place in [C17] that defines them. Nonetheless, we can get a precise picture from various places. [C17:6.2.5/20] says that pointer types describe objects whose values provide references to entities. [C17:6.3.2.3] specifies several things about pointers; in particular, it talks about null pointers. Thus, the picture is the following: a pointer is either an object designator or a null pointer (see the discussion in object-designators about lower-level addresses vs. higher-level object designators). However, in our defensive semantics, we also distinguish between non-null pointers that designate existing objects and non-null pointers that designate non-existing objects: the latter arise when such objects disappear, e.g. because they are in allocated storage and free is called, or because they are in automatic storage and their scope or frame that is popped. If the object no longer exists in this sense, the pointer is dangling. A C implementation has no direct information about whether a non-null pointer is valid or dangling, but our C model, which includes metadata, does.

Thus, we formalize a pointer as being either null or dangling or validly designating an object. The term `valid' here is perhaps not ideal, because in a sense a null pointer is a perfectly ``valid'' value, which may be used in well-written C code, so long as it is not deferenced. We may find a better term in the future, but for now here `valid' should be interpreted as `valid for dereferencing'.

The notion of pointer defined here is slighly different from the notion of pointer value defined in value. The latter consists of a pointer as defined here, plus a (referenced) type. Nonetheless, the pointer as defined here is the core of a pointer value, with the type being additional metadata. Thus, when clear from context, sometimes we will call `pointers' what are actually pointer values.

Subtopics

Pointer-case
Case macro for the different kinds of pointer structures.
Pointer-fix
Fixing function for pointer structures.
Pointer-equiv
Basic equivalence relation for pointer structures.
Pointer-valid
Pointerp
Recognizer for pointer structures.
Pointer-null
Pointer-dangling
Pointer-kind
Get the kind (tag) of a pointer structure.