Created on 2026-06-04.00:00:00 last changed 5 days ago
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.
(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.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2026-06-04 22:21:49 | admin | set | messages: + msg8596 |
| 2026-06-04 00:00:00 | admin | create | |