[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PIPE_BUF and read with SIZE < 0

From: Paul Jarc
Subject: Re: PIPE_BUF and read with SIZE < 0
Date: Fri, 25 Apr 2003 11:16:12 -0400
User-agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.3 (gnu/linux)

Robert Millan <> wrote:
> On Wed, Apr 23, 2003 at 05:50:49PM -0400, James A. Morrison wrote:
>> size_t is, at least on GNU systems, unsigned.  So specifing -1 will
>> give you a rather large value, perhaps even 2^32 - 1.

It's required to be unsigned by the C standard.

> I don't understand that. If size_t is an unsigned int, and i try to pass it
> a signed int, shouldn't the compiler require a cast? so that "(size_t) -1"
> should bring 2^32-1 and "-1" should fail to compile?

The cast is implicit, according to the C standard.  n869
"the arguments are implicitly converted, as if by assignment, to the
types of the corresponding parameters".

> sign conversions like that are dangerous, maybe i should file a wishlist
> bug on gcc?

It's definitely not a bug, but it might be useful to have a warning
option available.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]