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

From: Paul Eggert <[email-masked]>
Date: Sun, 28 Aug 2016 01:45:49 -0700

Dennis Clarke wrote:

> lib/regcomp.c will not compile with C99 strict compiler because of
> the usage of the non-standard "__restrict".

Thanks for the bug report. What are the diagnostics?

> I compiled and tested 2.25 both with and without
> the "restrict" and there was no measurable difference.

POSIX requires a 'restrict' here; see 
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/regcomp.html>. 
(Whether a compiler takes advantage of 'restrict' is not something under our 
control....)

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

The Gnulib code is supposed to be portable to compilers that do not support 
'restrict'. It does this by #defining 'restrict' to something equivalent, on 
compilers that are picky about 'restrict' for one reason or another. Sun C has 
this problem (actually C++), so the code #defines 'restrict' to '__restrict' to 
pacify it.

Sun C supports __restrict, so I'm puzzled as to why you're observing a problem. 
I did not have a problem building grep 2.25 on my Solaris 10 sparc host with 
Oracle Developer Studio 12.5. Please see the attached compressed build log; you 
might want to compare it with your build's output and debug any significant 
discrepancies (you can look in config.log).

One more thing: why use 'c99'? On Solaris it's typically better to use 'cc', as 
'c99' is mainly for portability pedants. If 'grep' builds with 'cc' but not with 
'c99', I'm inclined to declare victory with Oracle Developer Studio.