clad icon indicating copy to clipboard operation
clad copied to clipboard

Clang segfaults for program using header <random>

Open maxaehle opened this issue 1 year ago • 0 comments

Minimal example:

#include <random>
#include "clad/Differentiator/Differentiator.h"

double f(double x){
  std::mt19937 gen64;
  std::uniform_real_distribution<double> distribution(0.0,1.0);
  double rand = distribution(gen64);
  return x+rand;
}

int main(){
  auto f_dx = clad::differentiate(f, "x");
  f_dx.execute(3.14);
}

Expected behaviour: Code compiles. The derivative should evaluate to 1.

Observed behaviour: Clang segfaults.

Setup: Clad built from the GitHub master branch at commit 7449329197788a4ba523b179479d2483b66b12b8 on Ubuntu 22.04 with Clang 11. The segfault appears both with the GCC 12 libstdc++ and with the LLVM-11 libc++ (-stdlib=libc++).

Further information: The analogous code used to crash for Enzyme (EnzymeAD/Enzyme#1600), but likely for a different reason (missing support for long double in C++ header <random>), which has been fixed in EnzymeAD/Enzyme#1604.

maxaehle avatar Jan 05 '24 09:01 maxaehle