> -----Original Message-----
> From: Rainer Orth <r...@cebitec.uni-bielefeld.de>
> Sent: Friday, April 11, 2025 04:50
> To: gcc-patches@gcc.gnu.org
> Subject: [PATCH] cobol: Initialize regmatch_t portably [PR119217]
>
> The dts.h initialization of regmatch_t currently breaks Solaris
> compilation:
>
> In file included from /vol/gcc/src/hg/master/local/gcc/cobol/lexio.h:208,
>                  from /vol/gcc/src/hg/master/local/gcc/cobol/lexio.cc:36:
> /vol/gcc/src/hg/master/local/gcc/cobol/dts.h: In constructor
> ‘dts::csub_match::csub_match(const char*)’:
> /vol/gcc/src/hg/master/local/gcc/cobol/dts.h:36:35: error: invalid
> conversion from ‘int’ to ‘const char*’ [-fpermissive]
>    36 |       static regmatch_t empty = { -1, -1 };
>       |                                   ^~
>       |                                   |
>       |                                   int
>
>
> The problem is that Solaris regmatch_t has additional members before
> rm_so and rm_eo, as is always allowed by POSIX.1
>
> typedef struct {
>         const char      *rm_sp, *rm_ep; /* Start pointer, end pointer */
>         regoff_t        rm_so, rm_eo;   /* Start offset, end offset */
>         int             rm_ss, rm_es;   /* Used internally */
> } regmatch_t;
>
> so the initialization doesn't do what it's supposed to do.
>
> Fixed by initializing the rm_so and rm_eo members explicitly.
>
> Bootstrapped without regressions on amd64-pc-solaris2.11,
> sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu.
>
> Ok for trunk?

OK for trunk.

>
>       Rainer
>
> --
> --------------------------------------------------------------------------
> ---
> Rainer Orth, Center for Biotechnology, Bielefeld University
>
>
> 2025-04-08  Rainer Orth  <r...@cebitec.uni-bielefeld.de>
>
>       gcc/cobol:
>       PR cobol/119217
>       * dts.h (csub_match): Initialize rm_so, rm_eo fields explicitly.

Reply via email to