GNOME Bugzilla – Bug 662398
g_ascii_strtod does not reset errno
Last modified: 2011-10-22 05:55:07 UTC
After this commit: http://git.gnome.org/browse/glib/commit/?id=e02b062635a5b41f997a169eb8b48de902116d5a when HAVE_STRTOD_L is defined, g_ascii_strtod does not reset errno (because strtod_l doesn't), differently from what stated in the DOCS. This introduces regressions in code that diligently checks errno. Another difference, less important, between the two #ifdeff'ed branchs is that in one the pointer received is checked and if NULL a warning is printed, in the other not and, at least on my platform, passing NULL to strtod_l, core dumps. I think that it would be nice to document the different behaviour, regarding errno, of g_ascii_strto{u,}ll and g_ascii_strtod. For g_ascii_strtod something like: Differently from g_ascii_strtoull() and g_ascii_strtoll(), this function resets %errno ... and vice-versa for g_asci_strto{u,}ll.
The following fix has been pushed: e524379 Make g_ascii_strtod behave as documented
Created attachment 199688 [details] [review] Make g_ascii_strtod behave as documented The docs explicitly state that we reset errno, so lets do that, even if we just wrap strtod_l. Also move the argument check out of the ifdef.
If I read correctly the attachment, when HAVE_STRTOD_L is not defined there is a return before a declaration, probably it warns if not in C99 mode.