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.


> Date: Fri, 28 May 1999 16:34:48 +0200 (CEST)
> Reply-To: markus.oberhumer@jk.uni-linz.ac.at
> From: "Markus F.X.J. Oberhumer" <markus.oberhumer@jk.uni-linz.ac.at>

> Does this mean that the glibc 2.1 will not be -Wconversion
> warning free ?
> 
> I'm asking this as -Wconversion does have some usefulness
> when porting software across machines with different int sizes,
> and my "-O2 -Wconversion -W... -Werror" is a real-world
> example.
> 
> The problem as I see it that because of optimization parts
> of the implementation become visible in the interface, and
> the implementation is not fully warning free. This should
> get fixed, IMHO, probably by using int params in the
> internal functions.

You can eliminate all need for -Wconversion by supplying appropriate
prototypes for your functions (you may like to provide more than one
prototype).  For instance,

extern int bar();
extern int bar(short x, short y);

produces, with 'gcc -O2':

/tmp/z.c:2: conflicting types for `bar'
/tmp/z.c:2: An argument type that has a default promotion
/tmp/z.c:2: can't match an empty parameter name list declaration.
/tmp/z.c:1: previous declaration of `bar'

whereas the same thing with 'int' works fine.

Note that the order of the prototypes matters.  You must have the
empty prototype first.


There was an interesting bug in the PostgreSQL database server
recently that was of exactly this form, except that the authors were
casting the equivalent of 'bar' to 'int (*)()' and then calling it,
which of course doesn't work, and which they would have noticed much
earlier if they had included an empty prototype before the definition
of 'bar'.

-- 
Geoffrey Keating <geoffk@ozemail.com.au>

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