[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 15:13:52 UTC 2019


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

--- Comment #6 from David Eckardt <david.eckardt at frequenz.io> ---
> your example isn't actually using is at compile-time, because the strings are
> being generated at runtime.

That is right, and it made the cause even harder to find. Without thinking a
lot about it I changed SysTime.fromUnixTime to run at compile-time. Suddenly
toISOExtString(), called at run-time somewhere else in the code, returned a
different value.

Of course every programmer has one of these moments every once in a while. I
hope the following doesn’t sound too much like trolling, as there isn’t much
that can be done, I just can’t help finding it unfortunate that
• a new language feature, as useful as it might be, can cause an already
existing part of the standard library to suddenly return a different result,
• a naïve user can trigger it with a simple, subtle, seemingly innocent code
change (just add `static` before `immutable`),
• it seems to be unfixable in the affected standard library code and
• a more serious bug (incorrectly using UTC instead of local time) seems to be
prevented more by chance than by design.

--


More information about the Digitalmars-d-bugs mailing list