http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347

           Summary: G++-4.6 Solaris incorrectly defines _RESTRICT_KYWD to
                    __restrict
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: edwinto...@gmail.com
              Host: i386-pc-solaris2.10
            Target: i386-pc-solaris2.10
             Build: i386-pc-solaris2.10


Created attachment 24477
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24477
x.i

G++ 4.6 shows this error, G++ 4.3.3 doesn't:
/usr/include/spawn.h:42:14: error: expected ',' or '...' before 'argv'
/usr/include/spawn.h:50:14: error: expected ',' or '...' before 'argv'

Solaris defines posix_spawn like this:
extern int posix_spawn(
        pid_t *_RESTRICT_KYWD pid,
        const char *_RESTRICT_KYWD path,
        const posix_spawn_file_actions_t *file_actions,
        const posix_spawnattr_t *_RESTRICT_KYWD attrp,
        char *const argv[_RESTRICT_KYWD],
        char *const envp[_RESTRICT_KYWD]);

With GCC 4.6 I see this in preprocessed file:
# 358
"/usr/local/lib/gcc/i386-pc-solaris2.10/4.6.0/include-fixed/sys/feature_tests.h"
3 4
...
#if (defined(__STDC__) && defined(_STDC_C99))
#ifdef __cplusplus
#define _RESTRICT_KYWD  __restrict
#else
#define _RESTRICT_KYWD  restrict
#endif
#else
#define _RESTRICT_KYWD
#endif

With 4.3.3 I see this:
#if (defined(__STDC__) && defined(_STDC_C99))
#define _RESTRICT_KYWD  restrict
#else
#define _RESTRICT_KYWD
#endif

The system header is:
/usr/include/sys/feature_tests.h:
#if (defined(__STDC__) && defined(_STDC_C99))
#define _RESTRICT_KYWD  restrict
#else
#define _RESTRICT_KYWD
#endif

Don't know where the #define to __restrict on __cplusplus comes from, but it is
wrong.

GCC 4.6 is:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i386-pc-solaris2.10/4.6.0/lto-wrapper
Target: i386-pc-solaris2.10
Configured with: /home/chris/apps/compiler/gcc-4.6.0/configure
--enable-languages=c,c++ --disable-libgcj --with-as=/usr/local/bin/as
--with-gnu-as --with-ld=/usr/local/bin/ld --with-gnu-ld --disable-nls
Thread model: posix
gcc version 4.6.0 (GCC) 

GCC 4.3.3 is:
Using built-in specs.
Target: i386-pc-solaris2.10
Configured with: ../gcc-4.3.3/configure --prefix=/opt/csw/gcc4
--exec-prefix=/opt/csw/gcc4 --with-gnu-as --with-as=/opt/csw/bin/gas
--without-gnu-ld --with-ld=/usr/ccs/bin/ld --enable-nls --with-included-gettext
--with-libiconv-prefix=/opt/csw --with-x --with-mpfr=/opt/csw
--with-gmp=/opt/csw --enable-java-awt=xlib --enable-libada --enable-libssp
--enable-objc-gc --enable-threads=posix --enable-stage1-languages=c
--enable-languages=ada,c,c++,fortran,java,objc
Thread model: posix
gcc version 4.3.3 (GCC)

To reproduce bug just do this:
$ echo "#include <spawn.h>" >x.cpp
$ g++-4.6 x.cpp
In file included from x.cpp:1:0:
/usr/include/spawn.h:42:14: error: expected ',' or '...' before 'argv'
/usr/include/spawn.h:50:14: error: expected ',' or '...' before 'argv'

Preprocessed x.i attached.

Originally reported for ClamAV:
https://wwws.clamav.net/bugzilla/show_bug.cgi?id=2921

Reply via email to