This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ["Markus F.X.J. Oberhumer" <markus.oberhumer@jk.uni-linz.ac.at>] Bug#38311: <string.h> is not -Wconversion warning free


Andreas Jaeger <aj@arthur.rhein-neckar.de> writes:

|> This tiny program gets some warnings from <bits/string2.h> if compiled 
|> with -Wconversion:
|> #include <string.h>
|> 
|> int main(void)
|> {
|>   return 0;
|> }
|> 
|> $ gcc -Wconversion -Werror tst.c -O2
|> cc1: warnings being treated as errors
|> /usr/include/bits/string2.h: In function `__strsep_g':
|> In file included from /usr/include/string.h:346,
|>                  from tst.c:1:
|> /usr/include/bits/string2.h:1091: warning: passing arg 2 of `__strpbrk_c2' with different width due to prototype
|> /usr/include/bits/string2.h:1091: warning: passing arg 3 of `__strpbrk_c2' with different width due to prototype
|> /usr/include/bits/string2.h:1091: warning: passing arg 2 of `__strpbrk_c3' with different width due to prototype
|> /usr/include/bits/string2.h:1091: warning: passing arg 3 of `__strpbrk_c3' with different width due to prototype
|> /usr/include/bits/string2.h:1091: warning: passing arg 4 of `__strpbrk_c3' with different width due to prototype
|> 
|> I don't understand the warning at the moment.  Anybody else with a
|> fix?

That's because the function is declared expecting char parameters, but
strpbrk is passing ints due to the usual integer promotions.  This warning
is completely useless if only new-style declarations are used, and all
functions are properly prototyped.  The only way to avoid them is to
either turn all inline function into macros (*shrug*) or to change the
parameter types to int.

Andreas.

-- 
Andreas Schwab                                      "And now for something
schwab@issan.cs.uni-dortmund.de                      completely different"
schwab@gnu.org

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]