C backend: potential overflow in nano_time intrinsic
The code
return CExpr.call("clock", new List<>())
.mul(CExpr.uint64const(1_000_000_000))
.div(CExpr.ident("CLOCKS_PER_SEC"))
.ret();
may result in an overflow, see the documentatrion of clock:
The C standard allows for arbitrary values at the start of the program; subtract the value returned from a call to clock() at the start of the program to get maximum portability.
Fairly unlikely, but awful if it happens...
This was recently changed to:
https://github.com/tokiwa-software/fuzion/blob/8d00a84bed98f42a7699096e1e8808150df6329e/src/dev/flang/be/c/Intrinsics.java#L687-L703
but this seems to be equivalent to what Go for example is doing at:
https://cs.opensource.google/go/go/+/master:src/runtime/time_linux_amd64.s
So I believe this is fine.
Code has meanwhile been changed.