[metadata]
id = "EXP39-C"
type = "rule"
category = "EXP"
number = 39
title = "Do not access a variable through a pointer of an incompatible type"
description = """
Modifying a variable through a pointer of an incompatible type (other
thanunsigned char) can lead to unpredictable results.Subclause 6.2.7 of the C
Standard states that two types may be distinct yet compatible and addresses
preciselywhen two distinct types are compatible. This problem is often caused by
a violation of aliasing rules. The C Standard, 6.5, paragraph 7 [ISO/IEC
9899:2024], specifies those circumstances in which an object may or may not be
aliased. Accessing an object by means of any otherlvalueexpression (other
thanunsigned char) isundefined behavior 36.
"""
severity = "Medium"
likelihood = "Unlikely"
priority = "P2"
level = "L3"
cert_version = "2016 Edition (Wiki)"
last_modified = "Oct 29, 2025"
[rules.cert_c.EXP39-C]
enabled = true
[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/EXP39-C.+Do+not+access+a+variable+through+a+pointer+of+an+incompatible+type"
cwe = ["CWE-119", "CWE-125", "CWE-704", "CWE-123", "CWE-188"]