public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/98457] New: [d] writef!"%s" doesn't work with MonoTime / SysTick
@ 2020-12-27 23:56 witold.baryluk+gcc at gmail dot com
  2020-12-27 23:58 ` [Bug d/98457] " witold.baryluk+gcc at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: witold.baryluk+gcc at gmail dot com @ 2020-12-27 23:56 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug d/98457] [d] writef!"%s" doesn't work with MonoTime / SysTick
  2020-12-27 23:56 [Bug d/98457] New: [d] writef!"%s" doesn't work with MonoTime / SysTick witold.baryluk+gcc at gmail dot com
@ 2020-12-27 23:58 ` witold.baryluk+gcc at gmail dot com
  2021-04-19 15:29 ` ibuclaw at gdcproject dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: witold.baryluk+gcc at gmail dot com @ 2020-12-27 23:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Witold Baryluk <witold.baryluk+gcc at gmail dot com> ---
Godbolt link: https://godbolt.org/z/q3bzhP

with gcc trunk 20201217 and a bit more diagnostic

/opt/compiler-explorer/gcc-trunk-20201227/lib/gcc/x86_64-linux-gnu/11.0.0/include/d/core/time.d:2405:16:
error: static variable _ticksPerSecond cannot be read at compile time
 2405 |         return _ticksPerSecond[_clockIdx];
      |                ^
/opt/compiler-explorer/gcc-trunk-20201227/lib/gcc/x86_64-linux-gnu/11.0.0/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)";
      |                                                                        
                          ^
/opt/compiler-explorer/gcc-trunk-20201227/lib/gcc/x86_64-linux-gnu/11.0.0/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)";
      |                                                                        
                         ^
/opt/compiler-explorer/gcc-trunk-20201227/lib/gcc/x86_64-linux-gnu/11.0.0/include/d/std/format.d:3353:28:
note: called from here: val.toString()
 3353 |         put(w, val.toString());
      |                            ^
/opt/compiler-explorer/gcc-trunk-20201227/lib/gcc/x86_64-linux-gnu/11.0.0/include/d/std/format.d:3353:12:
note: called from here: put(w, val.toString())
 3353 |         put(w, val.toString());
      |            ^
/opt/compiler-explorer/gcc-trunk-20201227/lib/gcc/x86_64-linux-gnu/11.0.0/include/d/std/format.d:3672:21:
note: called from here: formatObject(w, val, f)
 3672 |         formatObject(w, val, f);
      |                     ^
/opt/compiler-explorer/gcc-trunk-20201227/lib/gcc/x86_64-linux-gnu/11.0.0/include/d/std/format.d:568:28:
note: called from here: formatValue(w, _param_2, spec)
  568 |                 formatValue(w, args[i], spec);
      |                            ^
/opt/compiler-explorer/gcc-trunk-20201227/lib/gcc/x86_64-linux-gnu/11.0.0/include/d/std/format.d:5767:28:
note: called from here: formattedWrite(w, fmt, _param_1)
 5767 |     auto n = formattedWrite(w, fmt, args);
      |                            ^
/opt/compiler-explorer/gcc-trunk-20201227/lib/gcc/x86_64-linux-gnu/11.0.0/include/d/std/format.d:5729:16:
note: called from here: format("%s", MonoTimeImpl(0L))
 5729 |         .format(fmt, Args.init);
      |                ^
/opt/compiler-explorer/gcc-trunk-20201227/lib/gcc/x86_64-linux-gnu/11.0.0/include/d/std/format.d:5733:2:
note: called from here: (*function () => null)()
 5733 | }();
      |  ^
/opt/compiler-explorer/gcc-trunk-20201227/lib/gcc/x86_64-linux-gnu/11.0.0/include/d/std/stdio.d:3754:15:
error: template instance std.format.checkFormatException!("�}�",
MonoTimeImpl!cast(ClockType)0) error instantiating
 3754 |     alias e = checkFormatException!(fmt, A);
      |               ^
<source>:4:14: note: instantiated from here: writef!("%s",
MonoTimeImpl!cast(ClockType)0)
    4 |   writef!"%s"(MonoTime.currTime());
      |              ^
/opt/compiler-explorer/gcc-trunk-20201227/lib/gcc/x86_64-linux-gnu/11.0.0/include/d/std/stdio.d:3755:5:
note: while evaluating: static assert(!e)
 3755 |     static assert(!e, e.msg);
      |     ^
Compiler returned: 1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug d/98457] [d] writef!"%s" doesn't work with MonoTime / SysTick
  2020-12-27 23:56 [Bug d/98457] New: [d] writef!"%s" doesn't work with MonoTime / SysTick witold.baryluk+gcc at gmail dot com
  2020-12-27 23:58 ` [Bug d/98457] " witold.baryluk+gcc at gmail dot com
@ 2021-04-19 15:29 ` ibuclaw at gdcproject dot org
  2021-04-19 17:29 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ibuclaw at gdcproject dot org @ 2021-04-19 15:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Reduced test:
---
void main() { writef!"%s"; }
---

Any error that deals with a symbol that has a formatting string in it will
trigger a segmentation fault.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug d/98457] [d] writef!"%s" doesn't work with MonoTime / SysTick
  2020-12-27 23:56 [Bug d/98457] New: [d] writef!"%s" doesn't work with MonoTime / SysTick witold.baryluk+gcc at gmail dot com
  2020-12-27 23:58 ` [Bug d/98457] " witold.baryluk+gcc at gmail dot com
  2021-04-19 15:29 ` ibuclaw at gdcproject dot org
@ 2021-04-19 17:29 ` cvs-commit at gcc dot gnu.org
  2021-04-19 20:42 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-19 17:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:dc7d1c74ffb1cc85e67984632f581d526c783770

commit r11-8250-gdc7d1c74ffb1cc85e67984632f581d526c783770
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Apr 19 18:45:32 2021 +0200

    d: Fix ICE in when formating a string with '%' or '`' characters (PR98457)

    The percentage character was being confused for a format specifier in
    pp_format(), whilst the backtick character was confused for the
    beginning of a quoted string in expand_d_format().

    Both are now properly escaped to avoid the ICE.

    gcc/d/ChangeLog:

            PR d/98457
            * d-diagnostic.cc (expand_d_format): Handle escaped backticks.
            (escape_d_format): New funtion.
            (verror): Call escape_d_format on prefixing strings.
            (vdeprecation): Likewise.

    gcc/testsuite/ChangeLog:

            PR d/98457
            * gdc.dg/pr98457.d: New test.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug d/98457] [d] writef!"%s" doesn't work with MonoTime / SysTick
  2020-12-27 23:56 [Bug d/98457] New: [d] writef!"%s" doesn't work with MonoTime / SysTick witold.baryluk+gcc at gmail dot com
                   ` (2 preceding siblings ...)
  2021-04-19 17:29 ` cvs-commit at gcc dot gnu.org
@ 2021-04-19 20:42 ` cvs-commit at gcc dot gnu.org
  2021-04-19 20:42 ` cvs-commit at gcc dot gnu.org
  2021-04-19 20:49 ` ibuclaw at gdcproject dot org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-19 20:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:19fc127321c7fe3962bd8b6c0064b224ab14aec7

commit r10-9718-g19fc127321c7fe3962bd8b6c0064b224ab14aec7
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Apr 19 18:45:32 2021 +0200

    d: Fix ICE in when formating a string with '%' or '`' characters (PR98457)

    The percentage character was being confused for a format specifier in
    pp_format(), whilst the backtick character was confused for the
    beginning of a quoted string in expand_d_format().

    Both are now properly escaped to avoid the ICE.

    gcc/d/ChangeLog:

            PR d/98457
            * d-diagnostic.cc (expand_d_format): Handle escaped backticks.
            (escape_d_format): New funtion.
            (verror): Call escape_d_format on prefixing strings.
            (vdeprecation): Likewise.

    gcc/testsuite/ChangeLog:

            PR d/98457
            * gdc.dg/pr98457.d: New test.

    (cherry picked from commit dc7d1c74ffb1cc85e67984632f581d526c783770)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug d/98457] [d] writef!"%s" doesn't work with MonoTime / SysTick
  2020-12-27 23:56 [Bug d/98457] New: [d] writef!"%s" doesn't work with MonoTime / SysTick witold.baryluk+gcc at gmail dot com
                   ` (3 preceding siblings ...)
  2021-04-19 20:42 ` cvs-commit at gcc dot gnu.org
@ 2021-04-19 20:42 ` cvs-commit at gcc dot gnu.org
  2021-04-19 20:49 ` ibuclaw at gdcproject dot org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-19 20:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:fda5b17a89e5066e19371ea138253bbb9cad262a

commit r9-9364-gfda5b17a89e5066e19371ea138253bbb9cad262a
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Apr 19 18:45:32 2021 +0200

    d: Fix ICE in when formating a string with '%' or '`' characters (PR98457)

    The percentage character was being confused for a format specifier in
    pp_format(), whilst the backtick character was confused for the
    beginning of a quoted string in expand_d_format().

    Both are now properly escaped to avoid the ICE.

    gcc/d/ChangeLog:

            PR d/98457
            * d-diagnostic.cc (expand_d_format): Handle escaped backticks.
            (escape_d_format): New funtion.
            (verror): Call escape_d_format on prefixing strings.
            (vdeprecation): Likewise.

    gcc/testsuite/ChangeLog:

            PR d/98457
            * gdc.dg/pr98457.d: New test.

    (cherry picked from commit dc7d1c74ffb1cc85e67984632f581d526c783770)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug d/98457] [d] writef!"%s" doesn't work with MonoTime / SysTick
  2020-12-27 23:56 [Bug d/98457] New: [d] writef!"%s" doesn't work with MonoTime / SysTick witold.baryluk+gcc at gmail dot com
                   ` (4 preceding siblings ...)
  2021-04-19 20:42 ` cvs-commit at gcc dot gnu.org
@ 2021-04-19 20:49 ` ibuclaw at gdcproject dot org
  5 siblings, 0 replies; 7+ messages in thread
From: ibuclaw at gdcproject dot org @ 2021-04-19 20:49 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Buclaw <ibuclaw at gdcproject dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
ICE has been fixed.  The library related errors are more to do with the version
of the D compiler in tree, rather than an issue with gdc itself.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-04-19 20:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-27 23:56 [Bug d/98457] New: [d] writef!"%s" doesn't work with MonoTime / SysTick witold.baryluk+gcc at gmail dot com
2020-12-27 23:58 ` [Bug d/98457] " witold.baryluk+gcc at gmail dot com
2021-04-19 15:29 ` ibuclaw at gdcproject dot org
2021-04-19 17:29 ` cvs-commit at gcc dot gnu.org
2021-04-19 20:42 ` cvs-commit at gcc dot gnu.org
2021-04-19 20:42 ` cvs-commit at gcc dot gnu.org
2021-04-19 20:49 ` ibuclaw at gdcproject dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).