Bug 85321 - const double arguments and -ffloat-store do not work together
const double arguments and -ffloat-store do not work together
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i686 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2003-02-27 18:41 EST by Need Real Name
Modified: 2007-04-18 12:51 EDT (History)
0 users

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

Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2003-02-27 18:41:03 EST
Description of problem:
extern double rightfunc(double);
extern double wrongfunc(double);
  if (rightfunc(0.75) != 0.75)
    return 1;
  const double x = 0.25;
  if (wrongfunc(x) != 0.25)
    return 2;
  return 0;

extern double rightfunc(double);
extern double wrongfunc(double);
double rightfunc(double t) { return t; }
double wrongfunc(const double t) { return t; }

all: right wrong
right: main.c funcs.c; gcc -O3 -o $@ main.c funcs.c
wrong: main.c funcs.c; gcc -O3 -ffloat-store -o $@ main.c funcs.c

With the three supplied files, use gmake to build.

The generated 'right' file works properly, but the
generated 'wrong' file generates incorrect code
for the 'wrongfunc' function:

        pushl   %ebp
        movl    %esp, %ebp
        subl    $8, %esp
        fldl    -8(%ebp)

Basically, the code uses memory that has not be set
to the value passed as the 'const double' argument.

Note that rightfunc() has a double argument, while
wrongfunc() has a const double argument.  Otherwise
they are the same.

The 'wrong' file is built with -ffloat-store while
the 'right' file is built without.

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

gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2)

How reproducible:

Steps to Reproduce:
1. Create specified main.c, funcs.c, and GNUmakefile
2. gmake
3. ./wrong

Actual Results:  ./wrong exits with 2.

Expected Results:  ./wrong should exit with 0 (like ./right).

Additional info:

This bug occurs when using -ffloat-store with
gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2),
with or without optimization.

It does not occur with gcc 2.91 or gcc 3.2.2.
Comment 1 Richard Henderson 2004-10-03 08:39:14 EDT
Indeed fixed in gcc 3.2.
Comment 2 Need Real Name 2004-10-03 19:15:17 EDT
So, 584 days after the bug report was submitted,
the only response is to repeat a point made in
the initial report and close the bug report?
Comment 3 Jakub Jelinek 2004-10-03 19:28:06 EDT
RHL 7.2 is not supported any longer, this will not be fixed in
GCC 2.96-RH.
Comment 4 Need Real Name 2004-10-03 19:49:52 EDT
But it was supported at the time that the
bug report was submitted.

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