This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
Fwd: Bug#39071: libc6-dev: ctype.h contains "-pedantic -O" warning
- To: libc-alpha@sourceware.cygnus.com
- Subject: Fwd: Bug#39071: libc6-dev: ctype.h contains "-pedantic -O" warning
- From: Joel Klecker <espy@debian.org>
- Date: Tue, 8 Jun 1999 05:49:34 -0700
- Cc: 39071-forwarded@bugs.debian.org
[ This is a forwarded bug from the Debian Bug Tracking System, please
keep 39071-forwarded@bugs.debian.org in any replies. Thanks.]
Debian version 2.1.1-10 is based on the final release of glibc 2.1.1.
The first case is considered a bug, yes?
I'm not sure of the second.
--- begin forwarded text
Return-path: <debian-bugs-dist-request@lists.debian.org>
Subject: Bug#39071: libc6-dev: ctype.h contains "-pedantic -O" warning
Reply-To: Kirk Hilliard <kirk@ghoti.com>, 39071@bugs.debian.org
To: submit@bugs.debian.org
From: Kirk Hilliard <kirk@ghoti.com>
Date: 06 Jun 1999 22:58:22 -0400
Message-ID: <87iu90n2cx.fsf@storm.x.ghoti.com>
Package: libc6-dev
Version: 2.1.1-10
Consider:
$ cat toupper.c
#include <stdio.h>
#include <ctype.h>
int main(void) {
char c;
c = toupper('a');
printf("toupper('a') = '%c'\n", c);
return 0;
}
$ gcc -pedantic -O toupper.c
toupper.c: In function `main':
toupper.c:5: warning: ANSI C forbids braced-groups within expressions
$
This warning here is new with libc6 2.1.
Other header files use __extension__ before braced-groups within
expressions, so here is a patch for ctype.h to suppress the warning.
------------------------------ 8< ------------------------------
--- /usr/include/ctype.h.orig Mon May 31 06:18:37 1999
+++ /usr/include/ctype.h Sun Jun 6 17:18:23 1999
@@ -165,6 +165,7 @@
#if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
# define __tobody(c, f, a) \
+ __extension__ \
({ int __res; \
if (sizeof (c) > 1) \
{ \
------------------------------ >8 ------------------------------
[I you really want to patch this, use -l since I messed with the
whitespace to make it fit.]
Even pedants should be able to optimize calls to toupper().
Kirk Hilliard
P.S. Here is another warning that is new for libc6 2.1.
$ cat strcmp.c
#include<string.h>
int main(void) {
void *v = "Hello, world.";
strcmp(v,v);
return 0;
}
$ gcc -Wpointer-arith -O strcmp.c
strcmp.c: In function `main':
strcmp.c:4: warning: pointer of type `void *' used in arithmetic
strcmp.c:4: warning: pointer of type `void *' used in arithmetic
strcmp.c:4: warning: pointer of type `void *' used in arithmetic
strcmp.c:4: warning: pointer of type `void *' used in arithmetic
strcmp.c:4: warning: pointer of type `void *' used in arithmetic
strcmp.c:4: warning: pointer of type `void *' used in arithmetic
$
At first this one did not bother me because it can be easily fixed by
explicitly casting the arguments of strcmp() to (string *). But the
warning doesn't say a thing about implicit casting. (Nor do -Wall or
-pedantic (or a slew of other warnings the upstream maintainer likes
to use) complain about the implicit casting.)
The source of the warning is in /usr/include/bits/string2.h:
#define __string2_1bptr_p(__x) \
((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
^^^^^^^^^
I think that ``__extension__'' only works with -pedantic -- at least I
couldn't get it to work its magic here. I don't know how to fix this.
Is it even worthy of being fixed?
--
To UNSUBSCRIBE, email to debian-bugs-dist-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
--- end forwarded text
--
Joel Klecker (aka Espy) <URL:mailto:espy@debian.org>
Debian Package Maintainer for the GNU C Library.