🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1949

possible gcc bug

#1949
From: Charlie Miller
Date: Wed, 16 Nov 1988 23:39
122 lines
3316 bytes

Hello, I have down-loaded (ftp'd) gcc, installed it per installation
directions and test-compiled a few programs.  This is my first
encounter with GNU software and I really appreciate it especially
the quality documentation.

Description of problem:  I have either done something stupid (most
likely) or there is a bug in the way some floating point functions are
handled.  Should not the compiler make a call to the 68881 when a
function like sin or cos is used?  Also when the following program is
compiled and run (same gcc compile line except exclusion of -S and
inclusion of the -lm library flag, see compile line below) the answer
printed out is this: i = NaN
I ran the same program using cc and it seemed to work fine,
including use of 68881 cos function.  Also, gcc seems to handle
floating point instructions like division just fine (including 68881
inline calls). Any help on this matter will be greatly appreciated.


Here's the pertinent information:

gcc version: 1.27 (I am using gcc 1.27 is because I want to install g++)
host computer: ISI V24 running UNIX 4.3bsd, M68020 w/M68881
tm.h -> tm-isi68.h 
md -> m68k.md
config.h -> config-m68k.h
aux-output.c -> output-m68k.c
gcc compile command line: gcc -m68020 -m68881 -S test.c
(I know the 68020 and 68881 are defaults anyway)

test program:

#include <math.h>
main()
{
double i;

	i = cos(.5); 
	printf("i = %f\n",i);
}

the assembly .s file produced: (notice the fmoved after the jbsr -cos)


#NO_APP
.globl fltused
.text
	.even
LC0:
	.double 0r0.5
LC1:
	.ascii "i = %f\12\0"
	.even
.globl _main
_main:
	link a6,#-8
	movel LC0+4,sp@-
	movel LC0,sp@-
	jbsr _cos
	fmoved fp0,a6@(-8)
	movel a6@(-4),sp@-
	movel a6@(-8),sp@-
	pea LC1
	jbsr _printf
L1:
	unlk a6
	rts



output from gcc -E:

# 1 "test.c"
# 1 "/usr/include/math.h"
 

extern double asinh(), acosh(), atanh();
extern double erf(), erfc();
extern double exp(), expm1(), log(), log10(), log1p(), pow();
extern double fabs(), floor(), ceil(), rint();
extern double lgamma();
extern double hypot(), cabs();
extern double copysign(), drem(), logb(), scalb();
extern int finite();



extern double j0(), j1(), jn(), y0(), y1(), yn();
extern double sin(), cos(), tan(), asin(), acos(), atan(), atan2();
extern double sinh(), cosh(), tanh();
extern double cbrt(), sqrt();
extern double modf(), ldexp(), frexp(), atof();




 


# 1 "test.c"

main()
{
double i;

	i = cos(.5); 
	printf("i = %f\n",i);
}


thanks
-charlie
========================================================================
-Charles E. Miller      
USPS Mail:              High Altitude Observatory
			P.O. Box 3000
			Boulder CO  80307
Phone:			(303) 497-1571
Internet:               cmiller@hao.ucar.edu
UUCP:                   {arizona,decvax,ihnp4}!hao!cmiller
========================================================================
Technical Details
Message-ID: <8811162339.AA05130@oscar.UCAR.EDU>
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!mcdchg!rutgers!tut.cis.ohio-state.edu!OSCAR.UCAR.EDU!cmiller

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!mcdchg!rutgers!tut.cis.ohio-state.edu!OSCAR.UCAR.EDU!cmiller
From: cmiller@OSCAR.UCAR.EDU (Charlie Miller)
Newsgroups: gnu.gcc.bug
Subject: possible gcc bug
Message-ID: <8811162339.AA05130@oscar.UCAR.EDU>
Date: 16 Nov 88 23:39:03 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 122