[Bug 272229] printf produces bogus output when printing double 0x00000000000000ff with %g

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 26 Jun 2023 19:09:38 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272229

            Bug ID: 272229
           Summary: printf produces bogus output when printing double
                    0x00000000000000ff with %g
           Product: Base System
           Version: 13.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: arm
          Assignee: freebsd-arm@FreeBSD.org
          Reporter: fuz@FreeBSD.org
                CC: diizzy@FreeBSD.org

Consider this test program:

#include <stdio.h>


int main()
{
        union intfloat {
                int i;
                double f;
        } intf;

        intf.i = 255;

        printf("%g\n", intf.f);
}

This should print (e.g. on aarch64):

    $ cc -o bug bug.c
    $ ./bug
    1.25987e-32

But on armv7 we get instead:

    $ ./bug
    e-309

Furthermore, there is an embedded NUL byte in the output:

    $ ./bug | od -c                                                             
    0000000   \0   e   -   3   0   9  \n                                    
    0000007

Preliminary debugging suggests that this could be because dtoa() returns an
empty string when vfprintf attempts the conversion.  Further debugging is
hindered as gdb cannot find debug symbols for dtoa (it seems to expect a source
file of different name than the actual file).

Among other things, this error causes devel/orc to fail during build.

-- 
You are receiving this mail because:
You are the assignee for the bug.