From owner-freebsd-hackers Tue Nov 7 21:28: 7 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from gray.westgate.gr (gray.westgate.gr [212.205.119.66]) by hub.freebsd.org (Postfix) with ESMTP id 2B21037B479 for ; Tue, 7 Nov 2000 21:28:02 -0800 (PST) Received: (from charon@localhost) by gray.westgate.gr (8.11.1/8.11.1) id eA85QUi58657; Wed, 8 Nov 2000 07:26:30 +0200 (EET) Date: Wed, 8 Nov 2000 07:26:30 +0200 From: Giorgos Keramidas To: andrew@ugh.net.au Cc: "Albert D. Cahalan" , hackers@FreeBSD.ORG, roam@orbitel.bg Subject: Re: umask(2) and -Wconversion Message-ID: <20001108072630.A58596@gray.westgate.gr> References: <200011080223.eA82Nxf392522@saturn.cs.uml.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from andrew@ugh.net.au on Wed, Nov 08, 2000 at 02:47:40PM +1000 X-PGP-Fingerprint: 3A 75 52 EB F1 58 56 0D - C5 B8 21 B6 1B 5E 4A C2 X-URL: http://students.ceid.upatras.gr/~keramida/index.html Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, Nov 08, 2000 at 02:47:40PM +1000, andrew@ugh.net.au wrote: > > On Tue, 7 Nov 2000, Albert D. Cahalan wrote: >> >> 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. Agreed. But, obviously, this is not what happens when I compile my test program posted earlier in this thread: 1 #include 2 3 #define VALUE 0 4 5 int func (short x); 6 7 int main (void) 8 { 9 int var = 10; 10 11 func(VALUE); 12 return 0; 13 } 14 15 int func (short var) 16 { 17 printf("var: %d\n", var); 18 return 0; 19 } Even though I have a cast at line 9 that one would expect to inhibit such a warning, the warning remains. This is what happens when one tries to compile programs that use umask(2) with -Wconversion. Macros defined in header, much like VALUE above are passed to a function that expects a `short', and the warning is issued. My original question was if this is not behavior that should be considered buggy, since the size of VALUE has not been determined to be equal to sizeof(int) when the #define occurs, or has it? - giorgos To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message