This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 85321 - const double arguments and -ffloat-store do not work together
const double arguments and -ffloat-store do not work together
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.2
i686 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  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:
Environment:
Last Closed: 2004-10-03 08:39:14 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

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

//////////funcs.c
extern double rightfunc(double);
extern double wrongfunc(double);
double rightfunc(double t) { return t; }
double wrongfunc(const double t) { return t; }

//////////GNUmakefile:
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:

wrongfunc:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $8, %esp
        fldl    -8(%ebp)
        leave
        ret

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:
Always

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.