From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11469 Path: news.gmane.org!.POSTED!not-for-mail From: Xiaowei Zhan Newsgroups: gmane.linux.lib.musl.general Subject: Different behavior (strtod) between musl and glibc Date: Tue, 13 Jun 2017 09:43:42 -0500 Message-ID: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a114f0314a732830551d87893" X-Trace: blaine.gmane.org 1497365079 28716 195.159.176.226 (13 Jun 2017 14:44:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 13 Jun 2017 14:44:39 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-11482-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jun 13 16:44:35 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dKn3a-0007Ay-4f for gllmg-musl@m.gmane.org; Tue, 13 Jun 2017 16:44:34 +0200 Original-Received: (qmail 4045 invoked by uid 550); 13 Jun 2017 14:44:36 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 3996 invoked from network); 13 Jun 2017 14:44:34 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=za5TeWBlso1DCuJ4rxTCCh/zyDJelcxWwEqmVdMJEzI=; b=fyiSwpJGRtAUoAEfSFS+1tloU/5xb9GTiznA+EpE7WalXYFK0L6sPW3vx7NKJJ+GTo owP9EChrIkROSfr76VepvfAey+dDgAVwjmKEiMxZe8YB6Rd8jMipltrYJZljxnvJa6j2 xe5MPU4+WNUGxXNR+qhL+fHbp090LW6wJ2+lE+QAcuWaRhRCOOQWFB+srjzz6Dn5sQg+ d+YSzKiv6Hc1ha6XKsIbbm8odqCwrFFV8FvicD64cbma0Mqd1+V8zaSngqBUkRrVnJH2 xSRKb8Qy0g7qCWvxA4dq1yVxxLlxJAkjK0FrqVMn2Gr+NyriIxYD85ikX4nnrEAEhpJ9 nnew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=za5TeWBlso1DCuJ4rxTCCh/zyDJelcxWwEqmVdMJEzI=; b=AqJCrVuw9f9+j4XC+83mII4oStH4yNBTqYewHLE0FjwnBrrUUNe4Q8/xcP05nExoYp ajG/2VkeKqHTifn2DV7GgyBzfHLsdREyAeP0mx73lT9+1eRRBPcR8c2k/ocQ6ytk2V6N 0xqefSvo8Op9Uf64sDe7GHDNs/FUUw5nhydadVx1duX9s7AXoDwFBMsWL6SJFcu75jE/ RFSWIeujE26eGaD7rteUFYWUs2FEXe25oKW3Dky6rOfaNYYYaAXQ5NSQpd9L92/U6TQI uZwSv4P9nd8Gtxwh7lAMtoYHNL7Lq0EJ/BpOhgPXPryogck8k8aQo/CpNB4o2OrqwpsQ LYGQ== X-Gm-Message-State: AKS2vOy/W1FNwq0XV9MMMuJ6gn1n9/KphAdimiIdmj45Iszkwyt9C8B2 3MlhgTcWSJ55La3WkgpNtW6tll2kt92J1NM= X-Received: by 10.129.132.149 with SMTP id u143mr3627206ywf.325.1497365062560; Tue, 13 Jun 2017 07:44:22 -0700 (PDT) Xref: news.gmane.org gmane.linux.lib.musl.general:11469 Archived-At: --001a114f0314a732830551d87893 Content-Type: text/plain; charset="UTF-8" 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 #include #include 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 --001a114f0314a732830551d87893 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

I notice that when pass a non-nu= meric char to strtod, musl will set errno to non-zero, but glibc will set e= rrno to zero.
I am curious why this difference exists, and whethe= r 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 arg= c, char** argv) {
=C2=A0 errno =3D 0;
=C2=A0 char input= [] =3D "NA023";
=C2=A0 strtod(input, NULL);
= =C2=A0 printf("errno =3D %d\n", errno);
=C2=A0 perror(&= quot;strtod");

=C2=A0 return 0;
}

Output (musl):

bash-= 4.3# ./main
errno =3D 22
strtod: Invalid argument

Output (glibc, Ubuntu 16.04):
&g= t; ./main
errno =3D 0
strtod: Success
<= br>


Best,
Xiaowei


--001a114f0314a732830551d87893--