We all know that C++ inherited unsafe semantics from C, but one would expect modern library features such as std::chrono to be carefully designed to avoid the old integer conversion bugs... right?

Not the case: it's very easy to silently cause truncation or overflow in correct-looking code, such as:

set_timeout(300s);

Try to get a compile-time diagnostic or at least a run-time error for this interface:
godbolt.org/z/K7fYGcx8h

Sign in to participate in the conversation
Mastodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!