Bug 204692 - command line printf outputs incorrect long doubles.
command line printf outputs incorrect long doubles.
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: gdb (Show other bugs)
5
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Alexandre Oliva
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-08-30 16:53 EDT by bkyoung
Modified: 2007-11-30 17:11 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-09-25 16:02:33 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description bkyoung 2006-08-30 16:53:24 EDT
Description of problem:
command line printf outputs incorrect long doubles.

Version-Release number of selected component (if applicable):
gdb-6.3.0.0-1.122

How reproducible:
Every Time

Steps to Reproduce:
1. Run provided C program.
2. Enter GDB, step into program
3. Enter command
printf "%Le\n", longdbl_one
  
Actual results:
Wrong value printed.

Expected results:
Correct value printed.

Additional info:

BEGIN main.c
#include <stdio.h>

long double longdbl_one=1;

int
main() {
  printf("%Le\n", longdbl_one);
  return 0;
}
END main.c

BEGIN Makefile
CC=gcc
CFLAGS=-O0 -g -m96bit-long-double -Wall

main: main.o
	$(CC) $(CFLAGS) -o $@ $^

main.o: main.s
	$(CC) $(CFLAGS) -c -o $@ $^

main.s: main.c
	$(CC) $(CFLAGS) -S -o $@ $^

clean:
	$(RM) *~
	$(RM) *.o
	$(RM) *.s
	$(RM) main
END Makefile

BEGIN OUTPUT
[bkyoung@flood gdb_bug]$ uname -a
Linux flood.searchm.com 2.6.16-1.2122_FC5smp #1 SMP Sun May 21 15:18:32 EDT 2006
i686 i686 i386 GNU/Linux
[bkyoung@flood gdb_bug]$ make
gcc -O0 -g -m96bit-long-double -Wall -S -o main.s main.c
gcc -O0 -g -m96bit-long-double -Wall -c -o main.o main.s
gcc -O0 -g -m96bit-long-double -Wall -o main main.o
[bkyoung@flood gdb_bug]$ gdb main
GNU gdb Red Hat Linux (6.3.0.0-1.122rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db
library "/lib/libthread_db.so.1".

(gdb) l
1	#include <stdio.h>
2	
3	long double longdbl_one=1;
4	
5	int
6	main() {
7	  printf("%Le\n", longdbl_one);
8	  return 0;
9	}
(gdb) b 8
Breakpoint 1 at 0x80483be: file main.c, line 8.
(gdb) r
Starting program: /home/bkyoung/proj/gdb_bug/main 
Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0x42b3a000
1.000000e+00

Breakpoint 1, main () at main.c:8
8	  return 0;
(gdb) p (long double) longdbl_one
$1 = 1
(gdb) printf "%Le\n", longdbl_one
-2.954930e-4276
(gdb) printf "%Le\n", (long double) longdbl_one
-3.373385e-4873
(gdb) c
Continuing.

Program exited normally.
(gdb) q
END OUTPUT
Comment 1 Jan Kratochvil 2006-08-31 20:05:52 EDT
Thanks for the bugreport. This bug is no longer present in RawHide/"development"
branch and the upcoming FC6. To temporarily workaround it please download:
http://download.fedora.redhat.com/pub/fedora/linux/core/development/source/SRPMS/gdb-6.5-5.fc6.src.rpm
and rebuild it on FC5 with:
rpmbuild --rebuild gdb*.src.rpm

To be CLOSED as RAWHIDE.

Note You need to log in before you can comment on or make changes to this bug.