sqc 0.4.13

Software Code Quality - CERT C compliance checker
[metadata]
id = "INT07-C"
type = "recommendation"
category = "INT"
number = 7
title = "Use only explicitly signed or unsigned char type for numeric values"
description = """
The three typeschar,signed char, andunsigned charare collectively called
thecharacter types. Compilers have the latitude to definecharto have the same
range, representation, and behavior aseithersigned charorunsigned char.
Irrespective of the choice made,charis a separate type from the other two and
isnotcompatible with either. Use onlysigned charandunsigned chartypes for the
storage and use of numeric values because it is the only portable way to
guarantee the signedness of the character types (seeSTR00-C. Represent
characters using an appropriate typefor more information on representing
characters). In this noncompliant code example, thechar-type variablecmay be
signed or unsigned. Assuming 8-bit, two's complement character types, this code
may print out eitheri/c = 5(unsigned) ori/c = -17(signed). It is much more
difficult to reason about the correctness of a program without knowing if these
integers are signed or unsigned.
"""
severity = "Medium"
likelihood = "Probable"
priority = "P12"
level = "L1"
cert_version = "2016 Edition (Wiki)"
last_modified = "May 20, 2025"

[rules.cert_c.INT07-C]
enabled = true

[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/INT07-C.+Use+only+explicitly+signed+or+unsigned+char+type+for+numeric+values"
cwe = ["CWE-682"]