Humbleness of comp.lang.c folks

June 26, 2013 at 4:06 pm | Posted in Programming | Leave a comment
Tags: , , ,

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 7.20.1.4p7:

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.

Advertisements

Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: