mailing list of musl libc
 help / color / mirror / code / Atom feed
* Explicit casts in ctype.h suppress compiler warnings
@ 2015-04-17 10:59 Alexander Monakov
  2015-04-17 16:49 ` Jens Gustedt
  2015-04-17 16:50 ` Rich Felker
  0 siblings, 2 replies; 13+ messages in thread
From: Alexander Monakov @ 2015-04-17 10:59 UTC (permalink / raw)
  To: musl

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-04-18  2:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-17 10:59 Explicit casts in ctype.h suppress compiler warnings Alexander Monakov
2015-04-17 16:49 ` Jens Gustedt
2015-04-17 16:52   ` Rich Felker
2015-04-17 18:24     ` Alexander Monakov
2015-04-17 18:35       ` Szabolcs Nagy
2015-04-17 19:43         ` Szabolcs Nagy
2015-04-17 20:21           ` Rich Felker
2015-04-17 20:32             ` Szabolcs Nagy
2015-04-17 20:34         ` Jens Gustedt
2015-04-17 21:36       ` Rich Felker
2015-04-18  2:03         ` Morten Welinder
2015-04-17 19:33     ` William Ahern
2015-04-17 16:50 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).