[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#39071: marked as forwarded (libc6-dev: ctype.h contains "-pedantic -O" warning)



Your message dated Tue, 8 Jun 1999 05:49:34 -0700
with message-id <v04205101b382b3e63ebb@[206.163.71.146]>
and subject line Fwd: Bug#39071: libc6-dev: ctype.h contains "-pedantic -O" warning
has caused the Debian bug report #39071,
regarding libc6-dev: ctype.h contains "-pedantic -O" warning
to be marked as having been forwarded to the upstream software
author(s) libc-alpha@sourceware.cygnus.com.

(NB: If you are a system administrator and have no idea what I'm
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Ian Jackson
(administrator, Debian bugs database)

Received: (at submit) by bugs.debian.org; 7 Jun 1999 03:04:16 +0000
Received: (qmail 336 invoked from network); 7 Jun 1999 03:04:14 -0000
Received: from gateway.greenbush.com (HELO ns1.greenbush.com) (ghoti@209.90.218.1)
  by master.debian.org with SMTP; 7 Jun 1999 03:04:14 -0000
Received: (from ghoti@localhost)
	by ns1.greenbush.com (8.9.3/8.8.7) id XAA06716;
	Sun, 6 Jun 1999 23:04:11 -0400
Sender: kirk@storm.x.ghoti.com
To: submit@bugs.debian.org
Subject: libc6-dev: ctype.h contains "-pedantic -O" warning
From: Kirk Hilliard <kirk@ghoti.com>
Date: 06 Jun 1999 22:58:22 -0400
Message-ID: <[🔎] 87iu90n2cx.fsf@storm.x.ghoti.com>
Lines: 78
X-Mailer: Gnus v5.3/Emacs 19.34

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?


Reply to: