mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Bug in atoll strtoll, the output of then differ
@ 2022-12-18  9:32 Domingo Alvarez Duarte
  2022-12-18  9:58 ` Markus Wichmann
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Domingo Alvarez Duarte @ 2022-12-18  9:32 UTC (permalink / raw)
  To: musl

Hello !

Doing some work with emscripten with this project 
https://github.com/mingodad/CG-SQL-Lua-playground I was getting some 
errors with the usage of "atoll" and with this small program to compare 
the output of "musl" and "glibc" I found what seems to be a bug in 
"atoll" because with "musl" it gives a different output than "strtoll".

=====

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
     const char *s = "9223372036854775808";
     long  long ll = atoll(s);
     long long ll2 = strtoll (s, (char **) NULL, 10);
     int imax = 0x7fffffff;
     printf("%s : %lld : %lld : %d : %d\n",  s, ll, ll2, imax, ll <= imax);
     return 0;
}

=====

Output from "glibc":

=====

9223372036854775808 : 9223372036854775807 : 9223372036854775807 : 
2147483647 : 0

=====

Output from "musl":

=====

9223372036854775808 : -9223372036854775808 : 9223372036854775807 : 
2147483647 : 1

=====

Cheers !


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-12-18 15:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-18  9:32 [musl] Bug in atoll strtoll, the output of then differ Domingo Alvarez Duarte
2022-12-18  9:58 ` Markus Wichmann
2022-12-18 10:22   ` Domingo Alvarez Duarte
2022-12-18 11:10     ` Markus Wichmann
2022-12-18 10:06 ` Quentin Rameau
2022-12-18 12:23 ` Szabolcs Nagy
2022-12-18 15:25 ` Rich Felker

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).