Jump to content
Alexander Sviridenkov

Bug in Android32 compiler

Recommended Posts

Dangerous bug in 10.4.2 / Android32 compiler (not sure about 64).

a, b : single

a is unitialized (= -nan in debugger), b = some value, f.e. 100.5;

if a <> b then  <code>, <code> is not executed.

 

ASM code:

 

if fValue <> aValue then
C5CCAD8C ED9D1A02         vldr s2, [sp, #8]
C5CCAD90 EEF70AC1         vcvt.f64.f32 d16, s2
C5CCAD94 ED901A00         vldr s2, [r0]
C5CCAD98 EEF71AC1         vcvt.f64.f32 d17, s2
C5CCAD9C EEF41BE0         vcmpe.f64 d17, d16
C5CCADA0 EEF1FA10         vmrs APSR_nzcv, fpscr
C5CCADA4 9001             str r0, [sp, #4]
C5CCADA6 ED8D0A00         vstr s0, [sp]
C5CCADAA D027             beq.n 0xc5ccadfc <Htmlcss.TMeasure.SetValue(float)+124>
C5CCADAC D626             bvs.n 0xc5ccadfc <Htmlcss.TMeasure.SetValue(float)+124>
C5CCADAE E7FF             b.n 0xc5ccadb0 <Htmlcss.TMeasure.SetValue(float)+48>


 

Share this post


Link to post

Not a bug. All comparison operators return false when one of the arguments is NaN. 

 

https://stackoverflow.com/questions/1565164/what-is-the-rationale-for-all-comparisons-returning-false-for-ieee754-nan-values

 

Also, bug reports are best at Quality Portal. Although not this one, because it's not a bug. 

Edited by David Heffernan
  • Like 3

Share this post


Link to post

Because of that I've build my NaN, INF+, INF- safe compare helpers, so that I can expect consistent behaviour.

I call those NaN_Safe operations, where I can also compare NaN, etc..

Edited by Rollo62

Share this post


Link to post
10 minutes ago, Rollo62 said:

Because of that I've build my NaN, INF+, INF- safe compare helpers, so that I can expect consistent behaviour.

I call those NaN_Safe operations, where I can also compare NaN, etc..

You don't need to do anything with INFs, they compare exactly as you'd expect.

Share this post


Link to post

Yes, but if I use a main and a shadow variable, which shall trigger when changed.

Then

if FMain <> FShadow then  

is very handy, when I can even assume that all numbers, NaN, IN's are running well.

 

Or when I send a value to a display, which need further formatting.

procedure DisplayValue( AValue : Single );
begin
    AValue := AValue / 1000.0;  // NaN / Inf is kept as is

    LDisplayText := DoConvertToText( AValue );  // can be 0.000; 123.456;  -.--- (=NaN);  -OL- (+Inf);   -UL- (-Inf);
end;

Also that can be interesting when not always need a lot of guad-code around it.

Edited by Rollo62

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×