Date: Tue, 26 Nov 2019 18:21:08 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 242067] libc: r354823 riscv64 has a fault in printf() where IEEE754-2008 fp128 data is output wrong Message-ID: <bug-242067-227-9swWwFHS4w@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-242067-227@https.bugs.freebsd.org/bugzilla/> References: <bug-242067-227@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D242067 --- Comment #6 from Dennis Clarke <dclarke@blastwave.org> --- Merely a follow up here to indicate this problem has been around since at least r350568 :=20 root@callisto:/home/dclarke/foo # uname -apKU FreeBSD callisto 13.0-CURRENT FreeBSD 13.0-CURRENT r350568 QEMU riscv risc= v64 1300038 1300038 root@callisto:/home/dclarke/foo #=20 root@callisto:/home/dclarke/foo # cat pi.c /************************************************* * The Open Group Base Specifications Issue 6 * IEEE Std 1003.1, 2004 Edition *************************************************/ #define _XOPEN_SOURCE 600 #include <stdio.h> #include <stdlib.h> #include <math.h> int main ( int argc, char *argv[]) { long double pi128 =3D 3.14159265358979323846264338327950288419716939937= 51L; double pi64 =3D M_PI; printf (" the sizeof(pi128) is %i\n", sizeof(pi128) ); printf (" the sizeof(pi64) is %i\n", sizeof(pi64) ); printf ("pi128 may be %44.38Lg\n", pi128 ); printf ("pi64 may be %18.16g\n", pi64 ); return ( EXIT_SUCCESS ); } root@callisto:/home/dclarke/foo #=20 root@callisto:/home/dclarke/foo # cat pi.s .file "pi.c" .option nopic .text .section .rodata .align 3 .LC2: .string " the sizeof(pi128) is %i\n" .align 3 .LC3: .string " the sizeof(pi64) is %i\n" .align 3 .LC4: .string "pi128 may be %44.38Lg\n" .align 3 .LC5: .string "pi64 may be %44.38Lg\n" .text .align 1 .globl main .type main, @function main: addi sp,sp,-64 sd ra,56(sp) sd s0,48(sp) addi s0,sp,64 mv a5,a0 sd a1,-64(s0) sw a5,-52(s0) lui a5,%hi(.LC0) ld a4,%lo(.LC0)(a5) sd a4,-32(s0) ld a5,%lo(.LC0+8)(a5) sd a5,-24(s0) lui a5,%hi(.LC1) fld fa5,%lo(.LC1)(a5) fsd fa5,-40(s0) li a1,16 lui a5,%hi(.LC2) addi a0,a5,%lo(.LC2) call printf li a1,8 lui a5,%hi(.LC3) addi a0,a5,%lo(.LC3) call printf ld a2,-32(s0) ld a3,-24(s0) lui a5,%hi(.LC4) addi a0,a5,%lo(.LC4) call printf ld a1,-40(s0) lui a5,%hi(.LC5) addi a0,a5,%lo(.LC5) call printf li a5,0 mv a0,a5 ld ra,56(sp) ld s0,48(sp) addi sp,sp,64 jr ra .size main, .-main .section .rodata .align 4 .LC0: .word 3306619320 .word 2221509004 .word 3041149649 .word 1073779231 .align 3 .LC1: .word 1413754136 .word 1074340347 .ident "GCC: (GNU) 8.2.0" root@callisto:/home/dclarke/foo #=20 root@callisto:/home/dclarke/foo #=20 root@callisto:/home/dclarke/foo # ./pi the sizeof(pi128) is 16 the sizeof(pi64) is 8 pi128 may be 2.0000076293945362811600603241536472604 pi64 may be 3.141592653589793 root@callisto:/home/dclarke/foo #=20 root@callisto:/home/dclarke/foo # echo "16o 1074340347p 1413754136pq" | dc 400921FB 54442D18 root@callisto:/home/dclarke/foo # echo "16o 1073779231p 3041149649p 2221509= 004p 3306619320pq" | dc=20 4000921F B54442D1 8469898C C51701B8 root@callisto:/home/dclarke/foo #=20 So that is perfect in memory and wrong in output.=20 --=20 Dennis Clarke RISC-V/SPARC/PPC/ARM/CISC UNIX and Linux spoken GreyBeard and suspenders optional --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-242067-227-9swWwFHS4w>