This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi,
I detected an bug in the handling of floating point constants in the GCC 3.3
version, delivered with SuSE Linux 8.2.
If there is not explicit an other definition an floating point constant has to
be handled as a double value. The GCC version from the SuSE 8.2 does not so.
If the value of the constant is in the range of float the compiler handles the
value as float value. That seems to be OK but if you compare a double
variable against the constant, the double variable will be converted into
float and that may fail.
Example:
A simple if-statement in 'C'
if(Block > 999999.)
will be compiled to:
fldl 0xfffffff8(%ebp) <-- Load the value of Block
fstps 0xffffffec(%ebp) <-- Store the value and convert
convert it float
flds 0xffffffec(%ebp) <-- Load value of Block
flds 0x815a51c <-- Load the constant
fxch %st(1) <-- Load value of st(1) to st(0)
fucompp <-- Compare the values
: :
: :
If the value of Block is bigger as the range of 'float' this code results in
an FPU-OVERFLOW exception.
The official GCC 3.3 version from gnu.org compiles the if-statement to:
fldl 0xfffffff8(%ebp) <-- Load the value of Block
fldl 0x815a51c <-- Load the constant
fxch %st(1) <-- Load value of st(1) to st(0)
fucompp <-- Compare the values
: :
: :
This works as expected without an exception.
There is a short example attached.
Regards,
Joerg Wleklik
Attachment:
main.cpp.tgz
Description: application/tgz
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |