constant signed/unsigned comparison warning

Per Bothner bothner@cygnus.com
Wed Sep 24 13:05:00 GMT 1997


> 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



More information about the Gcc mailing list