Latest toolchain throws error when including newlib's regex.h

Bernd Moessner berndmoessner80 at gmail.com
Sat Jan 20 17:31:28 UTC 2024


On 20.01.2024 16:49, Sebastian Huber wrote:
>
>
> On 19.01.24 21:31, Bernd Moessner wrote:
>> Dear all,
>>
>> I'm currently encountering an issue with the latest RTEMS toolchain 
>> (GCC 13) while attempting to build GoogleTest.
>>
>> Simple example, test.cpp with the following content:
>>
>> #include <sys/types.h>
>> #include <regex.h>
>>
>> compiled with
>>
>> ~/quick-start/install/tools/toolchain-arm/bin/arm-rtems6-g++ test.cpp
>>
>> gives me:
>>
>> In file included from test.cpp:2:
>> /home/blofeld/quick-start/install/tools/toolchain-arm/arm-rtems6/include/regex.h:99:45: 
>> error: expected primary-expression before '__restrict'
>>     99 |                         size_t, regmatch_t [__restrict], int);
>>        | ^~~~~~~~~~
>> /home/blofeld/quick-start/install/tools/toolchain-arm/arm-rtems6/include/regex.h:99:45: 
>> error: expected ']' before '__restrict'
>>     99 |                         size_t, regmatch_t [__restrict], int);
>>        | ^~~~~~~~~~
>>        |                                             ]
>> /home/blofeld/quick-start/install/tools/toolchain-arm/arm-rtems6/include/regex.h:99:45: 
>> error: expected ')' before '__restrict'
>>     99 |                         size_t, regmatch_t [__restrict], int);
>>        | ^~~~~~~~~~
>>        |                                             )
>> /home/blofeld/quick-start/install/tools/toolchain-arm/arm-rtems6/include/regex.h:98:16: 
>> note: to match this '('
>>     98 | int     regexec(const regex_t *__restrict, const char 
>> *__restrict,
>>        |                ^
>> /home/blofeld/quick-start/install/tools/toolchain-arm/arm-rtems6/include/regex.h:99:55: 
>> error: expected initializer before ']' token
>>     99 |                         size_t, regmatch_t [__restrict], int);
>>
>>
>> Is rejecting " [__restrict] " a bug in GCC, or should the signature 
>> of newlib`s /newlib/libc/include/regex.h be changed from
>>
>> int    regexec(const regex_t *__restrict, const char *__restrict,
>>              size_t, regmatch_t [__restrict], int);
>>
>> to
>>
>> int    regexec(const regex_t *__restrict, const char *__restrict,
>>              size_t, regmatch_t __restrict *, int);
>>
>> ? I would appreciate any insights or guidance you could provide on 
>> this matter.
>
> I would look at the pre-processed file (for example using 
> -save-temps=obj). Then I would send a patch fixing the issue to the 
> Newlib mailing list.
>

Thank you!

I found a bug report https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97477 
regarding this issue. Wondering why I havent seen the error earlier.

Besides, it should be regmatch_t * __restrict.

Regards Bernd





More information about the devel mailing list