Bug 204692 - command line printf outputs incorrect long doubles.
Summary: command line printf outputs incorrect long doubles.
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: gdb
Version: 5
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Alexandre Oliva
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-08-30 20:53 UTC by bkyoung
Modified: 2007-11-30 22:11 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-09-25 20:02:33 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description bkyoung 2006-08-30 20:53:24 UTC
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-09-01 00:05:52 UTC
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.