🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by E. Jason Scheck Mon, 02 Nov 1992 10:08
GCC zero handling bug
#54
Author: E. Jason Scheck
Date: Mon, 02 Nov 1992 10:08
39 lines
1538 bytes
Using gcc 2.2.2 or 2.3.1, sparc as the host, sun3os3 target, the following 
C program results in f = -0.0, rather than 0.0.

extern float f;
void func()
{
    f = 0.0;
}

The resultant assembly code is:

#NO_APP
gcc2_compiled.:
.text
	.even
.globl _func
_func:
	link a6,#0
	movel #0r-0.0,_f	; !!!!!!
L1:
	unlk a6
	rts

The problem is in sun3.h, which contains the following code:

#define ASM_OUTPUT_FLOAT_OPERAND(FILE,VALUE)                            \
  (REAL_VALUE_ISINF ((VALUE))                                           \
   ? (asm_fprintf (FILE, "%I0r%s99e999", ((VALUE) > 0 ? "" : "-")), 0)  \
   : (VALUE) == -0.0                                                    \
   ? (asm_fprintf (FILE, "%I0r-0.0"), 0)                                \
   : (asm_fprintf (FILE, "%I0r%.9g", (VALUE)), 0))

When value = 0 is given to the macro, the test for value == -0.0
evaluates as true.  I would guess that you would need to check
(value == 0.0 && value < 0.0); would the optimizer have a problem
with a statement of this type?

Jason Scheck
jasons@tv.tv.tek.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads