include::../description.adoc[]

== Noncompliant Code Example

----
uint8_t  * p1;
uint32_t * p2;
p2 = (uint32_t *)p1; // Noncompliant: Alignments may differ

struct foo {
  int i;
}

int main(int argc, char **argv) {
  struct foo* bar = (struct foo *)main; // Noncompliant
  bar->i = 2;
  return bar->i;
}
----

== See

* MISRA C:2004, 11.4 - A cast should not be performed between a pointer to object type and an integral type.
* MISRA {cpp}:2008, 5-2-3 - Casts to a base class from a derived class should not be performed on polymorphic types.
* https://www.securecoding.cert.org/confluence/x/tgAV[CERT, EXP36-C.] - Do not cast pointers into more strictly aligned pointer types
* http://cwe.mitre.org/data/definitions/588.html[MITRE, CWE-588] - Attempt to Access Child of a Non-structure Pointer
* http://cwe.mitre.org/data/definitions/704.html[MITRE, CWE-704] - Incorrect Type Conversion or Cast

ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]
