On 18/03/2024 14:54, Andreas Schwab via Gcc wrote:
On Mär 18 2024, David Brown wrote:

I think it would be possible to have an implementation where "signed
char" was 8-bit two's complement except that 0x80 would be a trap
representation rather than -128.

signed char cannot have padding bits, thus it cannot have a trap
representation.


The premise is correct (no padding bits are allowed in signed char), but does it follow that it cannot have a trap representation? I don't think the standards are clear either way here - I think the committee missed a chance to tidy up the description a bit more when C23 removed formats other than two's complement for signed integer types.

I also feel slightly uneasy using signed char for accessing object representations since the object representation is defined in terms of an unsigned char array, and conversion from unsigned char to signed char is implementation-defined. (This too could have been tightened in C23, as there is unlikely to be any implementation that does not do the conversion in the obvious manner.)

But I am perhaps worrying too much here.




Reply via email to