Date: Wed, 8 Nov 2000 14:47:40 +1000 (EST) From: andrew@ugh.net.au To: "Albert D. Cahalan" <acahalan@cs.uml.edu> Cc: hackers@FreeBSD.ORG, roam@orbitel.bg, keramida@ceid.upatras.gr Subject: Re: umask(2) and -Wconversion Message-ID: <Pine.BSF.4.21.0011081434400.94117-100000@starbug.ugh.net.au> In-Reply-To: <200011080223.eA82Nxf392522@saturn.cs.uml.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 7 Nov 2000, Albert D. Cahalan wrote: > of a fixed point argument except when the same as the default > promotion. <snip> > The C language is crufty. In the absense of a prototype, "short" is > promoted to "int". You wanted to be warned about that; you got it! short going to int would be a default promotion and so shouldn't produce a warning. > To avoid the warning, avoid passing anything but "int" and "double". > Maybe "long" is OK too, I forget. No the secret is not to have any function arguments that aren't ints, doubles etc. Its the cast from the default type on the stack to the non default type to get in the function that produces the warning I think. Take this example code: void foo(int i); void bar(short i); int main() { short s; foo(s); bar(s); return(0); } void foo(int i) { } void bar(short i) { } When compiled with -Wconversion you get: test10.c: In function `main': test10.c:10: warning: passing arg 1 of `bar' with different width due to prototype Andrew To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0011081434400.94117-100000>