[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] inttostr.c: suppress a warning
From: |
Bruno Haible |
Subject: |
Re: [PATCH] inttostr.c: suppress a warning |
Date: |
Wed, 24 Dec 2008 00:16:07 +0100 |
User-agent: |
KMail/1.9.9 |
Hi Jim,
> * lib/inttostr.c: Use #pragma GCC diagnostic ignored "-Wtype-limits"
Personally I find the -Wtype-limits warnings pointless[1], because the very
purpose of writing
char c = ...;
if (c >= 0 && c <= 0x7f)
is to avoid #ifdef in functions:
char c = ...;
if (true
#if CHAR_MIN < 0
&& c >= 0
#endif
#if CHAR_MAX > 0x7f
&& c <= 7f
#endif
)
In other words, the effort to get rid of the warning is too high.
Then why use the warning at all?
Additionally, #pragma GCC diagnostic hampers maintainability: Each time you move
code from a file to another, or split a file into two parts, you start wondering
to which code lines the #pragma GCC diagnostic applied. [2]
> +#pragma GCC diagnostic ignored "-Wtype-limits"
Older versions of GCC warn about unsupported pragmas [3]. Therefore IMO this
needs
to be enclosed in
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
#endif
Bruno
[1] http://lists.gnu.org/archive/html/bug-gnulib/2008-12/msg00046.html
[2] http://lists.gnu.org/archive/html/bug-gnulib/2008-10/msg00286.html
[3] http://lists.gnu.org/archive/html/bug-gnulib/2008-10/msg00295.html