The size of integer that is required when a pointer is converted to an integer is implementation-defined. Casting between a pointer and an integer type should be avoided where possible, but may be unavoidable when addressing memory mapped registers or other hardware specific features.


Note that {cpp} does not permit a pointer to be converted to any floating type.


== Noncompliant Code Example

[source,text]
----
struct S
{
  int32_t i;
  int32_t j;
};

void f ( S * s )
{
  int32_t p = reinterpret_cast< int32_t >( s ); // Noncompliant
}
----


== See

* MISRA {cpp}:2008, 5-2-9
* https://www.securecoding.cert.org/confluence/x/XAAV[CERT, INT36-C.] - Converting a pointer to integer or integer to pointer
* https://www.securecoding.cert.org/confluence/x/toAyAQ[CERT, INT11-CPP.] - Take care when converting from pointer to integer or integer to pointer

ifdef::env-github,rspecator-view[]

'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]

endif::env-github,rspecator-view[]
