Date: Mon, 24 Nov 1997 13:20:27 +1100 (EST) From: Andrew Cagney <cagney@tpgi.com.au> To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/5135: scanf accepts %Lg but treates it as %g Message-ID: <199711240220.NAA18459@b1.tpgi.com.au> Resent-Message-ID: <199711240630.WAA08423@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 5135 >Category: bin >Synopsis: scanf accepts %Lg but treates it as %g >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Nov 23 22:30:01 PST 1997 >Last-Modified: >Originator: Andrew Cagney >Organization: >Release: FreeBSD 2.2.5-RELEASE i386 >Environment: Vanilla 2.2.5 >Description: Burried away in the scanf documentation is: L Indicates that the conversion will be efg and the next pointer is a pointer to long double. (This type is not implemented; the L flag is currently ignored.) to be more precise, it assigns a `%g' value (32 bit float or single) to a `%Lg' destination (80 bit long double). I'm sorry but doing this is worse than stupid! >How-To-Repeat: One example, all GDB floating point is broken: $ gdb ... (gdb) print 1.0 $1 = 0 If you trace it through, c-exp.c:parse_number calls sscanf(...%Lg...). >Fix: For FreeBSD: o modify scanf so that for, %Lg (long double) it parses it as %lg (double) then extends/stores it as a long double. o Remove all support for %Lg in both printf and scanf. Some software (eg gdb) tests printf ("%Lg") and then assumes scanf also works. Consequently it is an all or nothing afair :-) For GDB: I'll see if I can get GDB changed so that its configure script separately checks for support of %Lg in scanf and printf. Have a nice day. Andrew >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711240220.NAA18459>