Arm Mbed OS support forum

NaN handling bug

I am not sure what is the right forum to report this, but it seems that the latest ARM Compiler (6.14) bundled with the Mbed Studio 1.1.0 has a NaN handling bug. The following code fragment
float a = 0.0f;
float aa = nanf("");
printf(“Nans are %d and %d\n”, isnan(aa), isnan(a));
gives the output
Nans are 0 and 0
which is incorrect (it should be Nans are 1 and 0). Previous version of the Mbed Studio ARM Compiler (I suppose it was version 6.13) gave the correct result. Platform used to test the code was NXP mbed LPC1768 dev board.

its not a bug, its a feature :slight_smile:


minimal_printf is default for mbed6.

I suppose that the problem is not with the printf but rather with the isnan() function. It returns integer value which should be printed correctly even using minimal printf (And I have the “target.printf_lib”: “std” line in mbed_app.json). I assume that the isnan() returns 0 incorrectly even if the argument is a NaN number.

Ahoj,

I do not know what version of compiler currently use the Online Compiler or MbedStudio Oline but the output is Nans are 1 and 0 from both.
But when it is compiled with the MbedStudio IDE, the output is Nans are 0 and 0.
So I can confirm different behavior.

Maybe @JoeA can help.

BR, Jan

Hi Jarkko, Jan

I’ve just checked and I can confirm that this difference in behavior is due to the Arm Compiler version update from 6.13 to 6.14.

Output in ARMC 6.13:
Nans are 1 and 0
Output in ARMC 6.14:
Nans are 0 and 0

I’ll raise this change internally and find out if it was expected.

Online Compiler vs Mbed Studio
There are a few differences between browser and desktop environments:

  • Online build system used in Online Compiler supports multiple versions of Arm Compiler. During a compilation, a version is chosen based on Mbed OS version inside of the program. Mbed Studio desktop on the other hand is always using a single version of Arm Compiler 6 for all programs. That version is being updated with Studio releases (currently 6.14.0 is being used)
  • Mbed Studio on desktop supports multiple profiles. Including custom profiles defined by user. Debug profile is used by default. Online compiler on the other hand does not support profile change. Develop profile is used.

Future
We are investigating the addition of profiles and compiler versions selection in-browser version of Studio. It is possible that it will be supported at some point. The decision hasn’t been made yet.

Thanks,
Arek - Mbed Studio team

1 Like