https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100005
--- Comment #4 from Thiago Macieira <thiago at kde dot org> --- That's an artificial (pun intended) limitation. In C++: template <typename Generator> int fill_array(Generator generator, unsigned long long *rand_array) Also errors out with the same error, but works if you do: fill_array([](auto x) { return _rdrand64_step(x); }, rand_array); The extra indirection shouldn't be required. PS: clang compiles the same code just fine.