Bug 85321 - const double arguments and -ffloat-store do not work together
Summary: const double arguments and -ffloat-store do not work together
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.2
Hardware: i686
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2003-02-27 23:41 UTC by Need Real Name
Modified: 2007-04-18 16:51 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2004-10-03 12:39:14 UTC

Attachments (Terms of Use)

Description Need Real Name 2003-02-27 23:41:03 UTC
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 12:39:14 UTC
Indeed fixed in gcc 3.2.

Comment 2 Need Real Name 2004-10-03 23:15:17 UTC
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 23:28:06 UTC
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 23:49:52 UTC
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.