lundi 20 avril 2020

Why does a std::random_device class member cause a segfault?

When I compile this code with clan g++ main.cpp && ./a.out I get a segfault (terminated by signal SIGSEGV (Adressbereichsfehler)).

gcc-Version 9.3.0
clang version 9.0.1

Run with Coliru here

#include <random>

struct Abra
{
  float hagrid[3000000];

  std::random_device voldemort{};
};

int main()
{
  Abra harry = {};
  return 0;
}

Why is that and how can I fix this? What I tried is to switch the declaration order of hagrid and voldemort but it still segfaults (Coliru example)




Aucun commentaire:

Enregistrer un commentaire