[MacPorts] #69374: gcc13 optimizer bug in ncurses

MacPorts noreply at macports.org
Mon Feb 19 16:52:57 UTC 2024


#69374: gcc13 optimizer bug in ncurses
---------------------------+--------------------
  Reporter:  ThomasDickey  |      Owner:  (none)
      Type:  defect        |     Status:  new
  Priority:  Normal        |  Milestone:
 Component:  ports         |    Version:
Resolution:                |   Keywords:
      Port:  gcc13         |
---------------------------+--------------------
Changes (by ryandesign):

 * port:   => gcc13


Old description:

> I noticed a problem in ncurses not displaying multibyte characters (used
> in line-drawing), and narrowed it down to a problem optimizing an
> expression in `tty_update.c`, using this
> chunk(https://github.com/ThomasDickey/ncurses-
> snapshots/blob/a98f459acb17efd5c1754d12efdfeba8cdb70e68/ncurses/curses.priv.h#L1458):
>
> ````
>                                 } else {
> \
>                                     int PUTC_j;
> \
>                                     for (PUTC_j = 0; PUTC_j < PUTC_n;
> ++PUTC_j) {   \
>                                         TR_PUTC(PUTC_buf[PUTC_j]);
> \
>                                         NCURSES_OUTC_FUNC
> (NCURSES_SP_ARGx PUTC_buf[PUTC_j]); \
>                                     }
> \
>                                 }
> \
> ````
>
> used here(https://github.com/ThomasDickey/ncurses-
> snapshots/blob/a98f459acb17efd5c1754d12efdfeba8cdb70e68/ncurses/tty/tty_update.c#L357):
>
> ````
>     PUTC(CHDEREF(ch));
> ````
>
> There's no issue reported in valgrind, address sanitizer, etc., in other
> environments, which would indicate a problem in ncurses, but with
> optimization that goes through the loop the expected number of times but
> fails to call the output `NCURSES_OUTC_FUNC` more than once.
>
> If it helps, I can attach the generated assembly for gcc12 (working) and
> gcc13 (nonworking).

New description:

 I noticed a problem in ncurses not displaying multibyte characters (used
 in line-drawing), and narrowed it down to a problem optimizing an
 expression in `tty_update.c`, using this
 chunk(https://github.com/ThomasDickey/ncurses-
 snapshots/blob/a98f459acb17efd5c1754d12efdfeba8cdb70e68/ncurses/curses.priv.h#L1458):

 {{{
                                 } else {
 \
                                     int PUTC_j;
 \
                                     for (PUTC_j = 0; PUTC_j < PUTC_n;
 ++PUTC_j) {   \
                                         TR_PUTC(PUTC_buf[PUTC_j]);
 \
                                         NCURSES_OUTC_FUNC (NCURSES_SP_ARGx
 PUTC_buf[PUTC_j]); \
                                     }
 \
                                 }
 \
 }}}

 used here(https://github.com/ThomasDickey/ncurses-
 snapshots/blob/a98f459acb17efd5c1754d12efdfeba8cdb70e68/ncurses/tty/tty_update.c#L357):

 {{{
     PUTC(CHDEREF(ch));
 }}}

 There's no issue reported in valgrind, address sanitizer, etc., in other
 environments, which would indicate a problem in ncurses, but with
 optimization that goes through the loop the expected number of times but
 fails to call the output `NCURSES_OUTC_FUNC` more than once.

 If it helps, I can attach the generated assembly for gcc12 (working) and
 gcc13 (nonworking).

--

-- 
Ticket URL: <https://trac.macports.org/ticket/69374#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list