Date: Tue, 10 Jun 2003 19:28:30 +0930 From: Malcolm Kay <malcolm.kay@internode.on.net> To: Sean Chittenden <sean@chittenden.org> Cc: questions@freebsd.org Subject: Re: gcc me harder: -Wconversion bug? Message-ID: <200306101928.30765.malcolm.kay@internode.on.net> In-Reply-To: <20030610092129.GP65470@perrin.int.nxad.com> References: <20030609230324.GL65470@perrin.int.nxad.com> <200306101825.33674.malcolm.kay@internode.on.net> <20030610092129.GP65470@perrin.int.nxad.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 10 Jun 2003 18:51, Sean Chittenden wrote:
> > It seems to me that this is doing exactly what is claimed for
> > -Wconversion. To quote from the gcc man page:
> > -Wconversion
> > Warn if a prototype causes a type conversion that
> > is different from what would happen to the same ar-
> > gument in the absence of a prototype. ...
> >
> > Now in the absence of a prototype for f() the argument true would be
> > promoted from char/bool to int before being passed to the
> > function. With the prototype in scope it is not promoted. Different
> > argument widths so warning delivered.
>
> % cpp test.c
> # 1 "test7.c"
> # 1 "<built-in>"
> # 1 "<command line>"
> # 1 "test7.c"
> # 1 "test7.h" 1
> # 13 "test7.h"
> void f(char b);
> # 2 "test7.c" 2
>
> int
> main(int argc, char *argv[]) {
> f((((char)1)));
>
> return(0);
> }
>
> void
> f(char b) {
> }
>
> Am I missing something that says that there isn't the prototype of the
> same width? Last time I checked my vision, f(char b) was the same as
> f(char b)... :-/ or am I missing something? I believe that gcc's
> promoting the char to an int or to some other non-1 byte width data
> type... but I'm not seeing how, where, or why. -sc
According to the man page we are comaring what does happen with
the prototype in scope with what would have happened if the prototype=20
was not there.
You are aware theat the rules of C require that in the absence of a proto=
type
actual integer calling arguments of less width than int (usually char and=
=20
short) must be promoted to int before the call?
Malcolm
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200306101928.30765.malcolm.kay>
