Authors: Jay Ghiron
Date: 2026-10-13
Submitted against: C23
Status: Open
The values of any padding bits are unspecified. A valid object representation of a signed integer type where the sign bit is zero is a valid object representation of the corresponding unsigned type, and shall represent the same value. For any integer type, the object representation where all the bits are zero shall be a representation of the value zero in that type.
(C23 6.2.6.2 "Integer types" paragraph 3.)
This paragraph says that any nonnegative value in a signed integer type shall be a valid object representation of the same value in the corresponding unsigned integer type. For example:
int main(){
union{int i;unsigned u;}u={};
return u.u;
}
The first member is initialized, but the object representation is guaranteed to be valid in both types and it is guaranteed the value represented in both types is the same. However, there is nothing saying the reverse:
int main(){
union{unsigned U;int I;}U={};
return U.I;
}
It appears that this could be undefined because the representation of
zero in unsigned corresponds to a non-value representation in int.
I do not think this was the intent, considering that va_arg allows
this conversion.
Modify C23 6.2.6.2 paragraph 3:
The values of any padding bits are unspecified. A valid object representation of a signed integer type where the sign bit is zero is a valid object representation of the corresponding unsigned type, and shall represent the same value. A valid object representation of an unsigned integer type where the most significant bit is zero is a valid object representation of the corresponding signed type, if any, and shall represent the same value. For any integer type, the object representation where all the bits are zero shall be a representation of the value zero in that type.
Note: In C2Y the text ", if any" can be deleted.