Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: update based on flurry of email

...

Any valid pointer to void can be converted to intptr_t or uintptr_t and back with no change in value (see INT11-EX2). The C Standard guaranteeds that a pointer to void  may be converted to or from a pointer to any object type and and back again and that the result must compare equal to the original pointer.  Consequently, converting directly from a char * pointer to a uintptr_t, as in this compliant solution, is allowed on implementations that support the uintptr_t type.

Code Block
bgColor#ccccff
langc
void f(void) {
  char *ptr;
  /* ... */
  uintptr_t number = (uintptr_t)(void *)ptr;  
  /* ... */
}

Noncompliant Code Example

...