static cast from float to int not working on ARM hardfp
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Radio |
New
|
Undecided
|
|||
Linaro GCC |
New
|
Undecided
|
Unassigned |
Bug Description
Hi, I spoke with a couple of you on IRC (as n|west) about this. There's a bug we're seeing (only on ARM hardfp; AFAIK it's only been tested on armv7 and of course various x86) in a complex file that is doing a static cast from a float received from the function call to an int. Much later the casted value is used as a tolerance in a comparison between two values in another templated function. The templated function instantiates several types of ints for comparison.
In the one case this bug affects us the value passed in as a float is 1.0. We static cast it to an int, and we know the difference between the values we are comparing is 1. The comparison 'difference > tolerance' is being made as 1 > 0 (true). If we add a print statement right after the static cast the behavior changes such that the comparison is what we expect to happen 'difference > tolerance' is 1 > 1 (false). In place of the print statement I added a function void lv_test_cast(int tolerance) that does the same kind of comparison. This function works as expected and when it is in place the comparison we care about behaves as expected.
$ /opt/oecore-
arm-oe-
This particular file is compiled using
$ /opt/oecore-
The original source is part of a GNU Radio library called VOLK, and I haven't been able to show the same behavior with anything simpler than the full version. The attached tar contains the original source file, pre-processed source, and a .S that come from adding -save-temps to the above g++ command. The cast in question is static_
Now tracked at https:/ /bugs.linaro. org/show_ bug.cgi? id=535