3 ms·
> But now, when any type might be larger than an uintmax_t? What do you do? Complain to POSIX so they add printf macro defines for all their implementation-siz
by formerly_proven 4y ago
> But now, when any type might be larger than an uintmax_t? What do you do?
Complain to POSIX so they add printf macro defines for all their implementation-sized integer types by the year 2100.
- teddyh 4y agoFor printf(), that would work. For sscanf(), POSIX could add macros there, too, but sscanf() does not detect integer overflow. That’s why the only previous solution was strtoimax() which does detect overflow.
- rwmj 4y agoscanf not detecting integer overflow is arguably another problem. It's usually the easiest way to parse numbers out of simple strings, but the lack of overflow detection is a problem. (Actually we use sscanf for this and ignore the overflow problem, as long as it doesn't cause any security or correctness concern.) IIRC glibc actually does overflow detection, so there's not anything inherently problematic with adding it.