Bug 84010 - required float->double convert optimized away
required float->double convert optimized away
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.1
ia64 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-02-10 17:35 EST by Robert Gottlieb
Modified: 2007-04-18 12:50 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-03 08:07:57 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Robert Gottlieb 2003-02-10 17:35:13 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.79C-CCK-MCD  [en] (X11; U; SunOS 5.9 sun4u)

Description of problem:
This problem occurs because of denormalized values. Consider the code

#include "stdio.h"

double zero = 0.0;

void test(double z) {
  printf( "z: %.16g\n", z );
}

int main() {
  float x = 1.175494351e-38;
  float y = 1.40129846e-45;

  printf( "x: %.7g %08x\n", (x+0.0), *((int*)&x) );
  printf( "y: %.7g %08x\n", (y+0.0), *((int*)&y) );

  test(y);
  test(y + zero);
  return 0;
}

The float value y is not explicitly converted from float to double. Most of the
time, this is ok, but for floating constant denorms, this results in the ia64
taking the float format bits as double format bits, which results in the
following output:

x: 1.175494e-38 00800000
y: 1.401298e-45 00000001
z: 2.65249473870659e-315
z: 1.401298464324817e-45

An explicit convert (fnorm.d) is required.

The compiler version is
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-101)


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Compile and link the (small) program included in the description
2. Run it
3.
    

Actual Results:  x: 1.175494e-38 00800000
y: 1.401298e-45 00000001
z: 2.65249473870659e-315
z: 1.401298464324817e-45

The 1st z, which does not have a convert from float to double (I examined the
assembly code), prints the wrong value. The second z,
which is converted to double by forcing an addition with a variable containing
the value 0, prints the correct value.

Expected Results:  The 1st z should have printed the same value as the 2nd z:
x: 1.175494e-38 00800000
y: 1.401298e-45 00000001
z: 1.401298464324817e-45
z: 1.401298464324817e-45



Additional info:

The compiler version is
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-101)

This is an Itanium 1 dual processor system.
Comment 1 Robert Gottlieb 2003-02-12 16:40:43 EST
See http://gcc.gnu.org/ml/gcc-patches/2001-04/msg00736.html
Comment 2 Richard Henderson 2004-10-03 08:07:57 EDT
Jim's patch is included in current sources.

Note You need to log in before you can comment on or make changes to this bug.