Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Nov 2000 23:30:05 +1000 (EST)
From:      andrew@ugh.net.au
To:        Giorgos Keramidas <keramida@ceid.upatras.gr>
Cc:        hackers@freebsd.org
Subject:   Re: umask(2) and -Wconversion
Message-ID:  <Pine.BSF.4.21.0011072318330.80082-100000@starbug.ugh.net.au>
In-Reply-To: <20001107120511.A98074@gray.westgate.gr>

next in thread | previous in thread | raw e-mail | index | archive | help


On Tue, 7 Nov 2000, Giorgos Keramidas wrote:

> discovered the following funny thing about -Wconversion and umask(2),

I spent quite a while trying to silence that warning in one of my programs
the otherday but I decided it was probably harmless and left it.

>          and vice versa, and conversions changing the width or signedness
>          of a fixed point argument except when the same as the default
>          promotion.

I think this is what we are hitting. From memory mode_t is a
u_int16_t. When you pass 0 (a 32 bit number) it gets cast to a 16 bit
number (change of width) and so produces the warning.

I think the reason that the cast doesn't help (or passing a u_int16_t) is
that when the 16 bit number gets passed it has to be placed on the 32 bit
stack which promotes it so you will always end up with a demotion when
the number is taken from the stack and given to umaks as a 16 bit int.

OTH I could be wrong :-) I haven't looked at the gcc source.

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.0011072318330.80082-100000>