This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: isprint core dump


On Mon, Jan 23, 2012 at 10:34 PM, Nellis, Kenneth  wrote:
> From: Eric Blake
>
>> No, but it DOES come from POSIX:
>> http://pubs.opengroup.org/onlinepubs/9699919799/functions/isprint.html
>>
>> And cygwin's behavior matches POSIX on this point; the bug is in your
>> program, not cygwin.
>
> Call me blown away by the level of support this function that
> dumps core is getting, when it could act sanely (IMHO) with a
> simple "if" statement! So much for defensive programming.

Like it or not, this is how C works. If you want defensive programming
with bounds checking and stuff, try Pascal or Java.

The man page of isprint states:
int isprint(int c);
These functions check whether c, which must have the value of an
unsigned char or EOF...

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If the argument has any other value, the behavior is undefined.

This is a contract between the library and you, the library user. You
promise to pass an argument between -1 and 255. isprint promises to
return a correct result.

You didn't keep your promise, so isprint is free to do anything it
wants including, but not limited to, opening your web browser at
http://nooooooooooooooo.com/

Csaba
-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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