This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 120a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2026-06-08


3197. Relaxed requirements for integer representations

Section: C.7.3  [diff.basic]     Status: open     Submitter: Jiang An     Date: 2026-06-04

(From submission #914.)

C++ does not have a requirement that an integer value 0 is represented as all-zero bits in the value representation; C does. See C23 6.2.6.2 paragraph 3:

... For any integer type, the object representation where all the bits are zero shall be a representation of the value zero in that type.

Suggested resolution:

Add a section in C.7.3 [diff.basic] as follows:

Affected subclause: 6.9.2 [basic.fundamental]
Change: C++ has relaxed rules for the representation of integer types compared to C.
[ Example: With the assumption that int has no padding bits:
  int i = 0;
  unsigned char a[sizeof(int)] = {};
  assert(memcmp(&i, a, sizeof(i)) == 0);   // guaranteed to hold in C; may fail in C++
-- end example]
Rationale: C++ has a more elaborate value model that de-emphasizes access to object representations.
Effect on original feature: Change of semantics of well-defined feature.
Difficulty of converting: Semantic transformation. Aggregate initialization should be used in lieu of memset.
How widely used: Occasionally. In particular, calloc and memset are expected to yield scalar subobjects with value 0.