Why doesn't if (isnan(value)) {...} work?

Good time dear ones.

For five hours I have been looking for how to fix the error, I can not understand what the point is.
There is something like this code:

float value = NAN;
different code, but the variable does not get a different value anywhere (the sensor is not connected)
char* rSensorItem::asString(const char* format, const float value)
  if (isnan(value)) {
    return malloc_stringf("\"%s\"", CONFIG_FORMAT_EMPTY);
  } else {
    return malloc_stringf(format, value);

format = “%f”

char * malloc_stringf(const char *format, ...)
  char*ret = nullptr;
  if (format) {
    // get the list of arguments
    va_list args;
    va_start(args, format);
    // calculate length of resulting string
    uint32_t len ​​= vsnprintf(nullptr, 0, format, args);
    // allocate memory for string
    ret = (char*)malloc(len+1);
    if (ret) {
      memset(ret, 0, len+1);
      vsnprintf(ret, len+1, format, args);
    } else {
      rlog_e(tagHEAP, "Out of memory!");
  return ret;

MCU crashes on line

uint32_t len ​​= vsnprintf(nullptr, 0, format, args);

I know for sure that NaN is written in value, but (isnan(value)) for some reason does not catch it. I don’t understand anything anymore…

Doing a simple test with

#include <Arduino.h>

void setup() {

void loop() {
  float val = NAN;
  if(isnan(val)) {
    Serial.println("Value was NaN.");
  } else {
    Serial.println("Value was not NaN.");    
  //attempt to print it
  Serial.println("Value: " + String(val));    


Value was NaN.
Value: nan

Can you reproduce that in your project?