Why errno is being set to EINVAL in the following code?

int main() {

 struct rlimit64 limit;
 
 limit.rlim_cur = static_cast<rlim64_t>(42);
 auto result = setrlimit64(RLIMIT_STACK, &limit);
 if (result == -1) {
  std::cout << errno << std::endl;
 }
}