Commit 90ef2296 by Janis Johnson Committed by Janis Johnson

re PR c/39035 (if( 0.0DF ) is considered true)

	PR c/39035
	* real.c (do_compare): Special-case compare of zero against
	decimal float value.

	* gcc.dg/dfp/pr39035.c: New test.

From-SVN: r143992
parent 4c51d57f
2009-02-06 Janis Johnson <janis187@us.ibm.com>
PR c/39035
* real.c (do_compare): Special-case compare of zero against
decimal float value.
2009-02-06 Joseph Myers <joseph@codesourcery.com>
PR c/36432
......
......@@ -905,15 +905,23 @@ do_compare (const REAL_VALUE_TYPE *a, const REAL_VALUE_TYPE *b,
/* Sign of zero doesn't matter for compares. */
return 0;
case CLASS2 (rvc_normal, rvc_zero):
/* Decimal float zero is special and uses rvc_normal, not rvc_zero. */
if (a->decimal)
return decimal_do_compare (a, b, nan_result);
/* Fall through. */
case CLASS2 (rvc_inf, rvc_zero):
case CLASS2 (rvc_inf, rvc_normal):
case CLASS2 (rvc_normal, rvc_zero):
return (a->sign ? -1 : 1);
case CLASS2 (rvc_inf, rvc_inf):
return -a->sign - -b->sign;
case CLASS2 (rvc_zero, rvc_normal):
/* Decimal float zero is special and uses rvc_normal, not rvc_zero. */
if (b->decimal)
return decimal_do_compare (a, b, nan_result);
/* Fall through. */
case CLASS2 (rvc_zero, rvc_inf):
case CLASS2 (rvc_normal, rvc_inf):
return (b->sign ? 1 : -1);
......
2009-02-06 Janis Johnson <janis187@us.ibm.com>
PR c/39035
* gcc.dg/dfp/pr39035.c: New test.
2009-02-06 Joseph Myers <joseph@codesourcery.com>
PR c/36432
......
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O" } */
/* DFP TR 24732 == WG14 / N1176, N1312 */
/* Based on a test from Fred Tydeman. */
extern void abort (void);
int failures = 0;
#ifdef DBG
#include <stdio.h>
#define FAILURE(MSG) { printf ("line %d: %s\n", __LINE__, MSG); failures++; }
#else
#define FAILURE(MSG) failures++;
#endif
/* Test runtime computations. */
void
runtime32 (void)
{
volatile _Decimal32 d;
d = 0.0DF;
if (d)
FAILURE ("0.0DF should be zero")
}
void
runtime64 (void)
{
volatile _Decimal64 d;
d = 0.0DD;
if (d)
FAILURE ("0.0DD should be zero")
}
void
runtime128 (void)
{
volatile _Decimal128 d;
d = 0.0DL;
if (d)
FAILURE ("0.0DL should be zero")
}
void
fold32 (void)
{
if (0.0DF)
FAILURE ("0.0DF should be zero")
}
void
fold64 (void)
{
if (0.0DD)
FAILURE ("0.0DD should be zero")
}
void
fold128 (void)
{
if (0.0DL)
FAILURE ("0.0DL should be zero")
}
int
main(void)
{
runtime32 ();
runtime64 ();
runtime128 ();
fold32 ();
fold64 ();
fold128 ();
if (failures != 0)
abort ();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment