This is the mail archive of the cygwin-developers 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: "C" character set (again)


According to Thomas Wolff on 1/8/2010 8:53 AM:
>> Per POSIX, printf is only defined if you pass a valid character string
>> as the format.
> Based on what?

Based on the definition of "character string".  POSIX only defines printf
if you pass a character string.  If you don't pass a valid a valid
character string, then you are no longer under the rules of POSIX.
>> That's why your behavior was undefined, and so ANYTHING can happen 
> No, not quite anything, APIs are not pure maths, Return Value conditions
> still have to be met.

No.  The point of undefined is that the return value is no longer
relevant.  The same is true if you call printf(NULL).  That is undefined
(NULL is not a valid character string).  Some platforms give a return
value and set errno to EFAULT, others trigger a SEGFAULT, and some might
even proceed to print whatever is in memory at address 0 (and that is just
three typical behaviors, others can be imagined).  But you can't guarantee
which, nor can POSIX standardize it, because it is UNDEFINED - you passed
in an invalid argument, so expect the unexpected.

-- 
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@byu.net


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