Humbleness of comp.lang.c folksJune 26, 2013 at 4:06 pm | Posted in Programming | Leave a comment
Tags: c programming language, comp.lang.c, harbison, Keith Thompson
I mostly hang on comp.lang.c and sometime discussion go deep into technical details of C language while solving a current problem. At comp.lang.c, folks do not go into details for the sake of details but to solve a particular problem. I got stuck in some issue and was continuously referring to comp.lang.c and then to K&R2 and then to H&S5 and I discovered one error in H&S 5. Actually I did not even know this till Keith Thompson credited and mailed me on the discovery (he mailed Harbison too). You can get the original post at googlegroups or velocityreviews . I thought it is better if I share his kind and humble words here on my blog (I am kind of quite late to post this but better late than never 🙂 ) :
Credit for finding this error goes to Arnuld Uttre, whom I’ve cc’ed on this e-mail (if I got his address right). It came up in a discussion on comp.lang.c, subject “strtoul() behavior”.
I have a first printing of H&S 5. On page 413, in the discussion of thestrto*() functions, it says (any typos are mine):
If no conversion is possible because the string does not match the expected number model (or is empty), then zero is returned, *ptr is set to the value of str, and errno is set to ERANGE.
In fact, errno is not set in this case. See C99 184.108.40.206p7:
If the subject sequence is empty or does not have the expected form, no conversion is performed; the value of nptr is stored in the object pointed to by endptr, provided that endptr is not a null pointer.
A quick experiment with one implementation shows that errno is in fact left as 0.
(A very small quibble: though the previous page mentions that ptr is ignored if it’s null, it might be worth changing “*ptr is set to …” to “*ptr (if it’s non-null) is set to …”. This is not actually necessary, but in my opinion it would make it slightly clearer.Feel free to ignore this.)
Copyright © 2013 Arnuld Uttre, Village – Patti, P.O – Manakpur, Tehsil – Nangal, Distt. – Ropar, Punjab (INDIA).
Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.