Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Fri, 17 Apr 2015 13:59:14 +0300 (MSK)
From: Alexander Monakov <amonakov@...ras.ru>
To: musl@...ts.openwall.com
Subject: Explicit casts in ctype.h suppress compiler warnings

For the following erroneous source code:

#include <ctype.h>
int f(char *c)
{
  return isdigit(c) || isspace(c);
}

GCC warns only for passing a pointer to isspace; isdigit is implemented as a
macro that casts its argument to unsigned, and the warning is suppresed
because the origin of the cast is in a system header.  Since isspace is
implemented with a static inline helper function, there is a warning.  With
glibc headers, no warning is issued in either case for a similar reason.

I think it would be nice if musl's ctype.h could aid the compiler in
diagnosing erroneous use, like it happens today for only for isspace() of all
macros declared there.  The cost of restructuring the header to achieve that
does not seem too high.  Thoughts?

Thanks.
Alexander

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.