After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 662398 - g_ascii_strtod does not reset errno
g_ascii_strtod does not reset errno
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.31.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-10-21 16:31 UTC by Massimo
Modified: 2011-10-22 05:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Make g_ascii_strtod behave as documented (1.23 KB, patch)
2011-10-21 19:00 UTC, Matthias Clasen
committed Details | Review

Description Massimo 2011-10-21 16:31:26 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.
Comment 1 Matthias Clasen 2011-10-21 19:00:37 UTC
The following fix has been pushed:
e524379 Make g_ascii_strtod behave as documented
Comment 2 Matthias Clasen 2011-10-21 19:00:39 UTC
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.
Comment 3 Massimo 2011-10-22 05:55:07 UTC
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.