Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Nov 2000 07:26:30 +0200
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        andrew@ugh.net.au
Cc:        "Albert D. Cahalan" <acahalan@cs.uml.edu>, hackers@FreeBSD.ORG, roam@orbitel.bg
Subject:   Re: umask(2) and -Wconversion
Message-ID:  <20001108072630.A58596@gray.westgate.gr>
In-Reply-To: <Pine.BSF.4.21.0011081434400.94117-100000@starbug.ugh.net.au>; from andrew@ugh.net.au on Wed, Nov 08, 2000 at 02:47:40PM %2B1000
References:  <200011080223.eA82Nxf392522@saturn.cs.uml.edu> <Pine.BSF.4.21.0011081434400.94117-100000@starbug.ugh.net.au>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <stdio.h>
     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 <sys/stat.h> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001108072630.A58596>