C++ Unordered_map.find crash

Продавец
Продавец
Статус
Оффлайн
Регистрация
13 Сен 2020
Сообщения
1,463
Реакции
722
the real issue here is the dll randomly crashing at runtime without exceptions / error messages...

I was trying to see what was causing the problem, and basically found out this function is not working properly.

The second line of code seems to be what's causing the crash...
FastFloatLerp:
Expand Collapse Copy
float FastFloatLerp(std::string identifier, bool state, float min, float max, float speed)

{

  static std::unordered_map<std::string, float> valuesMapFloat;


  auto value = valuesMapFloat.find(identifier); // -> CRASH HERE


  const float frameRateSpeed = speed * (1.f - ImGui::GetIO().DeltaTime);


  if (state) {

    if (value->second < max)

      value->second += frameRateSpeed;

  }

  else {

    if (value->second > min)

      value->second -= frameRateSpeed;

  }


  value->second = std::clamp(value->second, min, max);


  return value->second;

}

This is how i am calling the function...
calling of function:
Expand Collapse Copy
float anim = ImTricks::Animations::FastFloatLerp("theme_anim" , light, 0.f, 1.f, GetIO().DeltaTime * 3);
```

You can find the ImTricks code here: https://github.com/ALEHACKsp/imgui-tricks

This problem only verifies in my dll project...

I made another project that uses the same function called in the same way at the same time but everything works good...

So maybe some project setting / properties needs to be edited...
 
nice english u sell?
 
why russki try talk english
 
the real issue here is the dll randomly crashing at runtime without exceptions / error messages...

I was trying to see what was causing the problem, and basically found out this function is not working properly.

The second line of code seems to be what's causing the crash...
FastFloatLerp:
Expand Collapse Copy
float FastFloatLerp(std::string identifier, bool state, float min, float max, float speed)

{

  static std::unordered_map<std::string, float> valuesMapFloat;


  auto value = valuesMapFloat.find(identifier); // -> CRASH HERE


  const float frameRateSpeed = speed * (1.f - ImGui::GetIO().DeltaTime);


  if (state) {

    if (value->second < max)

      value->second += frameRateSpeed;

  }

  else {

    if (value->second > min)

      value->second -= frameRateSpeed;

  }


  value->second = std::clamp(value->second, min, max);


  return value->second;

}

This is how i am calling the function...
calling of function:
Expand Collapse Copy
float anim = ImTricks::Animations::FastFloatLerp("theme_anim" , light, 0.f, 1.f, GetIO().DeltaTime * 3);
```

You can find the ImTricks code here:
Пожалуйста, авторизуйтесь для просмотра ссылки.


This problem only verifies in my dll project...

I made another project that uses the same function called in the same way at the same time but everything works good...

So maybe some project setting / properties needs to be edited...

float lerpFloat = ImTricks::Animations::FastFloatLerp(label, *v, 0.f, 1.f, 0.05f);
(*v - bool)
 
ahahahaha brataaaaaaan

tut tochno learncpp.com

ti initialize std::unordered_map to be a nullptr and tryna find something in etot map

bebracodenz at its finest
 
Назад
Сверху Снизу