GNU bug report logs - #24323
"regcomp.c", line 467: error: syntax error before or at: preg

Previous Next

Package: grep;

Reported by: Dennis Clarke <dclarke <at> blastwave.org>

Date: Sun, 28 Aug 2016 03:43:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Dennis Clarke <dclarke <at> blastwave.org>
Subject: bug#24323: closed (Re: bug#24323: "regcomp.c", line 467: error:
 syntax error before or at: preg)
Date: Sun, 28 Aug 2016 19:59:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#24323: "regcomp.c", line 467: error: syntax error before or at: preg

which was filed against the grep package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 24323 <at> debbugs.gnu.org.

-- 
24323: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=24323
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Dennis Clarke <dclarke <at> blastwave.org>, 24323-done <at> debbugs.gnu.org
Subject: Re: bug#24323: "regcomp.c", line 467: error: syntax error before or
 at: preg
Date: Sun, 28 Aug 2016 12:58:39 -0700
[Message part 3 (text/plain, inline)]
I see the problem: the grep 2.25 tarball contains a regression from Gnulib that 
breaks compilation on some non-GCC compilers. Details below.

Dennis Clarke wrote:

> it has Oracle Studio 12.4 on it.

Ah, that explains it. 12.4 c99 supports __restrict__ but not __restrict, and 
this runs afoul of a porting bug in grep 2.25, based on Gnulib commit 
b7bc3c1a4e78add4cbad39ae1a0c4fb0747b483f (2016-04-09), which contains a 
regression that causes regcomp.c to not build on (non-GCC) compilers that lack 
__restrict. After grep 2.25 came out, this regression was fixed in Gnulib commit 
334d97f35cef30af0cf61c5eeaa0a67890a45578 (2016-06-08), which you can see here:

http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=334d97f35cef30af0cf61c5eeaa0a67890a45578

This Gnulib commit replaces __restrict with _Restrict_ in lib/regcomp.c, which 
fixes the regression. Applying this change to grep 2.25 should fix things for you.

I fixed the bug by installing the attached patch into the grep master branch on 
Savannah. This patch updates the Gnulib version to the current latest version, 
which pulls in the abovementioned bug fix.

> If not trivial then change the CFLAGS and give up on ye
> old -Xc strict compliance mode and switch to cc with -Xa and a pile of
> other flags for my pedantic debugging mode needs :
>
> mimas$ echo $CFLAGS
> -m64 -xtarget=ultra2e -xarch=sparcvis -xchip=ultra2e -xcache=generic -errfmt=error -erroff=%none -errshort=full -xstrconst -xildoff -m64 -xmemalign=8s -xnolibmil -Xc -xcode=pic32 -xregs=no%appl -xlibmieee -mc -g -xs -ftrap=%none -Qy -xbuiltin=%none -xdebugformat=dwarf -xunroll=1 -D_TS_ERRNO -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE

You might want to look here for new compiler options in 12.5:

https://docs.oracle.com/cd/E60778_01/html/E60742/gncki.html

> Hold on a sec here ... are we re-writing the POSIX standard C library
>  functions for some reason ?

Yes, as grep needs a regular expression matcher that works on data that can 
contain NUL bytes ('\0') and encoding errors. The POSIX API does not provide 
this, so grep supplies a substitute regex matcher on systems like Solaris that 
lack the extensions to POSIX that grep needs.
[0001-build-update-gnulib-submodule-to-latest.patch (text/x-diff, attachment)]
[Message part 5 (message/rfc822, inline)]
From: Dennis Clarke <dclarke <at> blastwave.org>
To: bug-grep <at> gnu.org
Subject: "regcomp.c", line 467: error: syntax error before or at: preg
Date: Sat, 27 Aug 2016 23:40:45 -0400
lib/regcomp.c will not compile with C99 strict compiler because of
the usage of the non-standard "__restrict".

I question the use here of the "restrict" for the purpose of
optimization so I compiled and tested 2.25 both with and without
the "restrict" and there was no measurable difference. The testsuite
passes fully regardless.

We may simply change "__restrict" to the C99 spec clean "restrict" or
remove it entirely with no worries.



--- ./lib/regcomp.c_backup      Sun Apr 10 16:50:01 2016
+++ ./lib/regcomp.c     Sun Aug 28 02:35:43 2016
@@ -464,7 +464,7 @@
    the return codes and their meanings.)  */

 int
-regcomp (regex_t *__restrict preg, const char *__restrict pattern, int 
cflags)
+regcomp (regex_t *restrict preg, const char *restrict pattern, int cflags)
 {
   reg_errcode_t ret;
   reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? 
RE_SYNTAX_POSIX_EXTENDED
@@ -523,7 +523,7 @@
    from either regcomp or regexec.   We don't use PREG here.  */

 size_t
-regerror (int errcode, const regex_t *__restrict preg, char *__restrict 
errbuf,
+regerror (int errcode, const regex_t *restrict preg, char *restrict errbuf,
          size_t errbuf_size)
 {
   const char *msg;




The compiler here was c99 in Oracle Studio 12.5 on Solaris 10 sparc
with strict C99 compliance mode enforced.

Dennis Clarke






This bug report was last modified 8 years and 264 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.