This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: constant signed/unsigned comparison warning


> But that's not correct.  If you're writing INT_MAX + 1 bytes, then the
> return value is INT_MIN, and that's an indication of success.

If you are writing INT_MAX + 1, then it is not going to fit in ssize_t
or int, and I doubt the code would work in any case.  Perhaps if you
are really lucky and/or the people writing the kernel and libc have been
very careful, it might work.

Posix.1 says:
	If the value of nbyte is greater than {SSIZE_MAX}, the result is
	implementation defined.

Still, if people (such as kernel implementors) want that sort of code
to work, then it seems perfectly reasonable to add a cast to say
"yes, I have thought about this, and I know what I'm doing."

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]