This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
weird __restrict error with g++-2.95.2 + glibc-2.1.93
- To: gcc-bugs at gcc dot gnu dot org
- Subject: weird __restrict error with g++-2.95.2 + glibc-2.1.93
- From: "Adam J. Richter" <adam at yggdrasil dot com>
- Date: Sun, 10 Sep 2000 17:57:38 -0700
This is a bug that I submitted to libc-alpha@sourceware.cygnus.com,
but I think it is more likely a g++-2.95.2 bug.
>Submitter-Id: net
>Originator: Adam J. Richter
>Organization:
<organization of PR author (multiple lines)>
>Confidential: no
>Synopsis: Possibly bogus g++ complaint about glibc-2.1.93/time/sys/time.h
>Severity: non-critical
>Priority: low
>Category: libc
>Class: sw-bug
>Release: libc-2.1.93
>Environment:
<machine, os, target, libraries (multiple lines)>
Host type: i686-pc-linux-gnu
System: Linux baldur 2.4.0-test8 #5 SMP Sat Sep 9 02:52:39 PDT 2000 i686 unknown
Architecture: i686
Addons: linuxthreads
Build CC: gcc
Compiler version: 2.95.2 19991024 (release)
Kernel headers: 2.4.0-test8
Symbol versioning: yes
Build static: yes
Build shared: yes
Build pic-default: no
Build profile: yes
Build omitfp: no
Build bounded: no
Build static-nss: no
Stdio: libio
>Description:
Sorry if this submission is a duplicate. I tried to get glibcbug
to also send a copy to gcc-bugs@gcc.gnu.org and to me, and I did not
receive a copy, so I fear that the bug I described yesterday has not
been submitted. This is my second attempt.
I know glibc-2.95.2 is not for use in production systems, and I also
realize that this bug is more likely a g++ bug, and may even be
mistakes the developers of all of the effected software. I am just
submitting this report to the relevant parties in the on the chance
that it is a real bug in g++ or glibc.
Under glibc-2.1.93, a number of C++ software components,
such as harmony, gmod and a number of others, have been getting the
following g++ error:
/usr/include/sys/time.h:69: two or more data types in declaration of `__tz'
It turns out that running g++ on a file that contains just the
one line "#include <sys/time.h>" will produce this error.
/usr/include/sys/time.h is installed from
glibc-2.1.93/time/sys/time.h. Here is an excerpt of the lines leading up
to line 69 in glibc-2.1.93/time/sys/time.h:
57 #if defined __USE_GNU || defined __USE_BSD
58 typedef struct timezone *__timezone_ptr_t;
59 #else
60 typedef void *__timezone_ptr_t;
61 #endif
62
63 /* Get the current time of day and timezone information,
64 putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
65 Returns 0 on success, -1 on errors.
66 NOTE: This form of timezone information is obsolete.
67 Use the functions and variables declared in <time.h> instead. */
68 extern int gettimeofday (struct timeval *__restrict __tv,
69 __timezone_ptr_t __restrict __tz) __THROW;
Eliminating the __restrict keyword or replacing __timezonee_ptr_t
with either "void*" or "struct timezone*" on line 69 makes the error
go away.
Bracketting "#include <sys/time.h>" in 'extern "C" {...}' has no
effect.
>How-To-Repeat:
% cat > foo.C << EOF
#include <sys/time.h>
EOF
% g++ -c foo.C
/usr/include/sys/time.h:69: two or more data types in declaration of `__tz'
>Fix:
Either of the following changes to line 69 of
glibc-2.1.93/time/sys/time.h should be useable workarounds:
1. delete the "__restrict" keyword, or perhaps just
bracket it in "#ifndef __cplusplus"..."#endif"
2. Even uglier, if "#if defined __USE_GNU || _USE_BSD" to
select between the following changes:
a. replace __timezone_ptr_t with "void*"
b. replace __timezone_ptr_t with "struct timezone*"
As for the correct fix, it will probably be apparent to somebody
who is more of a C++ person (I can't really say if the error is in glibc,
g++ or the source code that experiences the error).