From: Xiaowei Zhan <zhanxw@gmail.com>
To: musl@lists.openwall.com
Subject: Different behavior (strtod) between musl and glibc
Date: Tue, 13 Jun 2017 09:43:42 -0500 [thread overview]
Message-ID: <CABVSaD+0bg2Xe2eWRx27hRpBZAo_AaqZHjDP0ag2V42Gqc8vXA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 652 bytes --]
Hello,
I notice that when pass a non-numeric char to strtod, musl will set errno
to non-zero, but glibc will set errno to zero.
I am curious why this difference exists, and whether it is necessary to
make strtod in musl behave similarly to glibc.
Here is the toy program:
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
errno = 0;
char input[] = "NA023";
strtod(input, NULL);
printf("errno = %d\n", errno);
perror("strtod");
return 0;
}
Output (musl):
bash-4.3# ./main
errno = 22
strtod: Invalid argument
Output (glibc, Ubuntu 16.04):
> ./main
errno = 0
strtod: Success
Best,
Xiaowei
[-- Attachment #2: Type: text/html, Size: 1199 bytes --]
next reply other threads:[~2017-06-13 14:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-13 14:43 Xiaowei Zhan [this message]
2017-06-13 14:53 ` Khem Raj
2017-06-14 13:44 ` Florian Weimer
2017-06-14 17:26 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABVSaD+0bg2Xe2eWRx27hRpBZAo_AaqZHjDP0ag2V42Gqc8vXA@mail.gmail.com \
--to=zhanxw@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).