From owner-freebsd-hackers Tue Nov 7 20:47:49 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from starbug.ugh.net.au (starbug.ugh.net.au [203.31.238.37]) by hub.freebsd.org (Postfix) with ESMTP id EB34F37B479 for ; Tue, 7 Nov 2000 20:47:46 -0800 (PST) Received: by starbug.ugh.net.au (Postfix, from userid 1000) id 70A42A82B; Wed, 8 Nov 2000 15:47:40 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by starbug.ugh.net.au (Postfix) with ESMTP id 6CF6F5465; Wed, 8 Nov 2000 14:47:40 +1000 (EST) Date: Wed, 8 Nov 2000 14:47:40 +1000 (EST) From: andrew@ugh.net.au To: "Albert D. Cahalan" Cc: hackers@FreeBSD.ORG, roam@orbitel.bg, keramida@ceid.upatras.gr Subject: Re: umask(2) and -Wconversion In-Reply-To: <200011080223.eA82Nxf392522@saturn.cs.uml.edu> Message-ID: X-WonK: *wibble* MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, 7 Nov 2000, Albert D. Cahalan wrote: > of a fixed point argument except when the same as the default > promotion. > 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