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-29


3197. Relaxed requirements for integer representations

Section: C.7.3  [diff.basic]     Status: review     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 [SUPERSEDED]:

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.

CWG 2026-06-26

In lieu of the above suggested resolution, CWG opted to eliminate this difference vs. C.

Possible resoluition:

Change in 6.9.2 [basic.fundamental] paragraph 11 as follows:

The types char, wchar_t, char8_t, char16_t, and char32_t are collectively called character types. The character types, bool, the signed and unsigned integer types, and cv-qualified versions (6.9.5 [basic.type.qualifier]) thereof, are collectively termed integral types. A synonym for integral type is integer type.

[Note 8: Enumerations (9.8.1 [dcl.enum]) are not integral; however, unscoped enumerations can be promoted to integral types as specified in 7.3.7 [conv.prom]. —end note]

If the bits in the value representation of an object of integer type other than bool all have value zero, the object contains the value zero (7.3.2 [conv.lval]). If the bits in the value representation of an object of type bool all have value zero, the object contains the value false.