Open
Description
https://godbolt.org/z/r8Yd7nhzc
Not sure standard requires this behavior or not, but it is undefined behavior in IMPLICI T conversion, in naive code, which is expected to be working. Huge disappointment in std::chrono
#include <chrono>
#include <iostream>
int main() {
std::chrono::nanoseconds ns = std::chrono::milliseconds::max();
std::cout << ns.count() << "|" << ns.max().count();
}
Output:
/opt/compiler-explorer/gcc-13.1.0/include/c++/13.1.0/bits/chrono.h:225:38: runtime error: signed integer overflow: 9223372036854775807 * 1000000 cannot be represented in type 'long int'
-1000000|9223372036854775807
Expected: max count of nanoseconds
Additionaly: clang (when writed as one line) ignores undefined behavior while constant folding