Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Well, in C++ int('1' * 4301) is a perfectly valid expression, but it evaluates to 210749, not 4301.


Or some other value.

If sizeof(int)=2, the result is undefined.


Whether evaluating that expression results in undefined behaviour also depends on the basic execution character set and the bit width of the machine byte.


Not if CHAR_BIT is 10 or more!


I wonder how much software will fail on platforms where CHAR_BIT is not 8.


I worked with some MCUs whose only redeeming quality was their cost that had CHAR_BIT=16. The answer is basically everything. It made string processing was profoundly annoying, even for C.


Is it one of TI’s custom ISAs for their DSP line? The TMS430, for example, has a 16 bit char. That causes some unintuitive looking code to fight that.


No, it was with xap [1] chips. TI is also on my list of annoying chip vendors because they're one of the few companies still making big endian ARM chips, which should die in a fire.

[1] https://en.wikipedia.org/wiki/XAP_processor


I've seen 2 programs in my life that checked for CHAR_BIT (and one was a toy decimal -> binary converter). My guess is basically all of it.


it doesn't evaluate to 4301 in Python either ;-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: