🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #54

GCC zero handling bug

#54
From: 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
Technical Details
Message-ID: <199211030208.AA04649@soul.tv.tek.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!noc.near.net!hri.com!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tv.tv.tek.COM!jasons

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!noc.near.net!hri.com!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tv.tv.tek.COM!jasons
From: jasons@tv.tv.tek.COM (E. Jason Scheck)
Newsgroups: gnu.gcc.bug
Subject: GCC zero handling bug
Message-ID: <199211030208.AA04649@soul.tv.tek.com>
Date: 2 Nov 92 10:08:11 GMT
Sender: gnulists@ai.mit.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 39
Approved: bug-gcc@prep.ai.mit.edu