[Bug d/98457] New: [d] writef!"%s" doesn't work with MonoTime / SysTick

witold.baryluk+gcc at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Dec 27 23:56:33 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98457

            Bug ID: 98457
           Summary: [d] writef!"%s" doesn't work with MonoTime / SysTick
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: witold.baryluk+gcc at gmail dot com
  Target Milestone: ---

void main() {
  import std.stdio;
  import core.time : MonoTime;
  writef!"%s"(MonoTime.currTime());
}


Doesn't compile with gdc 10.2.1:

$ gdc test_monotime.d 
/usr/lib/gcc/x86_64-linux-gnu/10/include/d/core/time.d:2405:16: error: static
variable _ticksPerSecond cannot be read at compile time
 2405 |         return _ticksPerSecond[_clockIdx];
      |                ^
/usr/lib/gcc/x86_64-linux-gnu/10/include/d/core/time.d:2418:99: note: called
from here: ticksPerSecond()
 2418 |             return "MonoTime(" ~ signedToTempString(_ticks, 10) ~ "
ticks, " ~ signedToTempString(ticksPerSecond, 10) ~ " ticks per second)";
      |                                                                        
                          ^
/usr/lib/gcc/x86_64-linux-gnu/10/include/d/core/time.d:2418:98: note: called
from here: signedToTempString(ticksPerSecond(), 10u)
 2418 |             return "MonoTime(" ~ signedToTempString(_ticks, 10) ~ "
ticks, " ~ signedToTempString(ticksPerSecond, 10) ~ " ticks per second)";
      |                                                                        
                         ^
/usr/lib/gcc/x86_64-linux-gnu/10/include/d/std/format.d:3353:28: note: called
from here: val.toString()
 3353 |         put(w, val.toString());
      |                            ^
/usr/lib/gcc/x86_64-linux-gnu/10/include/d/std/format.d:3353:12: note: called
from here: put(w, val.toString())
 3353 |         put(w, val.toString());
      |            ^
/usr/lib/gcc/x86_64-linux-gnu/10/include/d/std/format.d:3672:21: note: called
from here: formatObject(w, val, f)
 3672 |         formatObject(w, val, f);
      |                     ^
/usr/lib/gcc/x86_64-linux-gnu/10/include/d/std/format.d:568:28: note: called
from here: formatValue(w, _param_2, spec)
  568 |                 formatValue(w, args[i], spec);
      |                            ^
/usr/lib/gcc/x86_64-linux-gnu/10/include/d/std/format.d:5767:28: note: called
from here: formattedWrite(w, fmt, _param_1)
 5767 |     auto n = formattedWrite(w, fmt, args);
      |                            ^
/usr/lib/gcc/x86_64-linux-gnu/10/include/d/std/format.d:5729:16: note: called
from here: format("%s", MonoTimeImpl(0L))
 5729 |         .format(fmt, Args.init);
      |                ^
/usr/lib/gcc/x86_64-linux-gnu/10/include/d/std/format.d:5733:2: note: called
from here: (*function () => null)()
 5733 | }();
      |  ^

(null):0: confused by earlier errors, bailing out



Adding manually .toString() makes it work (at the expense of possible extra
allocation).

No issues in ldc2 1.24.0 or dmd2 2.095.0-beta.1

It doesn't look like issue in phobos, but something deeper.


More information about the Gcc-bugs mailing list