inside main(), a call is made to function testo() which simply returns a
double(1415.149). The correct double value is returned only if main.c has
#include <f.h>, which is where testo() is declared.
I've compiled two versions of this program, with and without the include line,
withinclude.a.out and withoutinclude.a.out, respectively. The assembled code
varies slightly between the two, withoutinclude.a.out having the following
extra three lines shown below (with xxx):
realnum=testo();
8048384: e8 2b 00 00 00 call 80483b4 <testo>
8048389: 50 push %eax xxx
804838a: db 04 24 fildl (%esp) xxx
804838d: 8d 64 24 04 lea 0x4(%esp),%esp xxx
8048391: dd 5d f8 fstpl 0xfffffff8(%ebp)
fildl takes the pushed value (0xa) and stores it onto the floating point stack
and then fetched by fstpl, which is then stored in realnum.
This code does NOT get generated if there is an #include <f.h> in main.c
--
Summary: incorrect double value returned from function testo()
called from main().
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gnassre at earthlink dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25284