Hacker News new | ask | show | jobs
by astrange 1514 days ago
Related, an integer bug that can't be fixed in C is that "unsigned short" promotes to "int" instead of "unsigned int", so this doesn't produce the result you want.

  unsigned x = (unsigned short)65535 * (unsigned short)65535;
(It overflows even though it's less than UINT_MAX, and worse it's UB.)