diff options
author | Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> | 2025-05-08 09:29:56 +0200 |
---|---|---|
committer | Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> | 2025-05-08 09:29:56 +0200 |
commit | 12d6fa2a21140166181ae3be7711d60e62c569d7 (patch) | |
tree | cb172f5423ba8e057d5308d065640a8525987cb6 | |
parent | bac74b0d0141a440275797a059c2b43978cd9e1c (diff) | |
download | gcc-12d6fa2a21140166181ae3be7711d60e62c569d7.zip gcc-12d6fa2a21140166181ae3be7711d60e62c569d7.tar.gz gcc-12d6fa2a21140166181ae3be7711d60e62c569d7.tar.bz2 |
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.
2025-04-08 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
gcc/cobol:
PR cobol/119217
* dts.h (csub_match): Initialize rm_so, rm_eo fields explicitly.
-rw-r--r-- | gcc/cobol/dts.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/cobol/dts.h b/gcc/cobol/dts.h index c345dc7..dfd7c4c 100644 --- a/gcc/cobol/dts.h +++ b/gcc/cobol/dts.h @@ -33,7 +33,8 @@ namespace dts { : input(input) , first(NULL), second(NULL), matched(false) { - static regmatch_t empty = { -1, -1 }; + static regmatch_t empty; + empty.rm_so = empty.rm_eo = -1; regmatch_t& self(*this); self = empty; } |