[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#706207: gcc-4.6, gcc-4.7: invalid optimization when doing double -> int math and conversion (on big endian archs(?))



Package: gcc-4.6,gcc-4.7
Version: 4.6.3-15
Severity: normal

Dear Maintainer,

this bug manifest itself on ia64, powerpc and s390x where gcc-4.6 is
used and the optmized code (-O2) fails to produce correct math
results.

This code from libgd2:src/gd.c:clip_1d:

  *y1 -= m * (*x1 - mindim);

where

  m = (double) -0.050000
  *x1 = -200
  mindim = 0
  *y1 = 15

results in *y1 = 4, which is incorrect value, since it should be 5.

Most simple workaround, which allows gcc to produce correct value:

  *y1 -= (int)(m * (*x1 - mindim));

Assigning to some other variable also works ok:

  int t;
  t = m * (*x1 - mindim);
  *y1 -= t;

Compiling with -O0 also produces correct value.

gcc-4.7 is unfortunatelly also affected.

I just hope we don't compile the nuclear reactor controls with gcc :)

O.

-- System Information:
Debian Release: 7.0
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: ia64

Kernel: Linux 2.6.32-5-mckinley (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages gcc-4.6 depends on:
ii  binutils        2.22-8
ii  cpp-4.6         4.6.3-15
ii  gcc-4.6-base    4.6.3-15
ii  libc6.1         2.13-38
ii  libgcc1         1:4.7.2-5
ii  libgmp10        2:5.0.5+dfsg-2
ii  libgomp1        4.7.2-5
ii  libmpc2         0.9-4
ii  libmpfr4        3.1.1-1
ii  libquadmath0    4.7.2-5
ii  libunwind7-dev  0.99-0.3
ii  zlib1g          1:1.2.7.dfsg-13

Versions of packages gcc-4.6 recommends:
ii  libc6.1-dev  2.13-38

Versions of packages gcc-4.6 suggests:
pn  gcc-4.6-doc          <none>
pn  gcc-4.6-locales      <none>
pn  libgcc1-dbg          <none>
pn  libgomp1-dbg         <none>
pn  libmudflap0-4.6-dev  <none>
pn  libmudflap0-dbg      <none>
pn  libquadmath0-dbg     <none>

-- no debconf information


Reply to: