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);
  };
}

where:
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!");
    };
    va_end(args);
  };
  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() {
  Serial.begin(115200);
}

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));    
  delay(1000);
}

gives

Value was NaN.
Value: nan

Can you reproduce that in your project?