[Issue 19808] SysTime gives different results at compile vs. run time execution

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 20 12:09:06 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19808

--- Comment #5 from David Eckardt <david.eckardt at frequenz.io> ---
> I don't know what would happen if you called toISOExtString at
> compile-time. I'd have to test it. It might not even work due to using a
> pointer comparison.

I tried it:

import std.datetime.systime: SysTime;
import std.datetime.timezone: UTC;
pragma(msg, SysTime.fromUnixTime(0, UTC()).toISOExtString());

fails with “typecons.d(2145): Error: reinterpretation through overlapped field
`stripped` is not allowed in CTFE”.

Consider SysTime.fromUnixTime(0, LocalTime()) at compile-time: The `is`
comparison` could really cause a bug here, using UTC instead. However,

static immutable ctfe = SysTime.fromUnixTime(0, LocalTime());

fails with “concurrency.d(2488): Error: static variable `lock` cannot be read
at compile time”. So we are safe.

--


More information about the Digitalmars-d-bugs mailing list