emil-e/rapidcheck

gen::set fails to compile with noexcept setters and C++17

nooploop opened this issue · 2 comments

I'm trying to compile some of my tests in C++17 and suddenly i get issues with noexcept setters.

struct X
{
  void setValue(int v) noexcept { value = v; }
  int value;
};

...

auto gen = rc::gen::build<X>(rc::gen::set(&X::setValue));  // fails to compile

So far i tried to build it in XCode9 and XCode10 on Mac. It compiled fine in C++14. Removing noexcept specifier also solves the issue.

I don't fully understand rapidcheck internals, so i cannot say if it's a library issue or some compiler problem.

C++17 introduced noexcept into the type system so it is more likely that this is a library issue as some previously C++14 valid code becomes invalid C++17 one. Since noexcept functions can be "converted" to "throwing" I doubt the problem is conversion related (akin to going from const to mutable), as it is in your case.

I would assume the issue is related to the type detection facilities since noexcept function types are not detected but I will have to dig a bit deeper to see if this is the case.

At the time of writing the code, I had no idea that noexcept was going to be part of the type signature in C++17 so I probably wasn't too careful about this. Regardless, Can this is even be handled without ifdefs?

Haven't had time to look into it myself, I'm afraid.