https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81134
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is not a bug, the conditional expression using ?: instantiates both
branches, so although one branch uses the terminating case, the other one
doesn't.
You can make the code valid like this:
template <int N, int M>
struct GCD
{
static const int value
= std::conditional<(N>M), GCD<N%M, M>, GCD<N, M%N>>::type::value;
};
Or like this:
template <int N, int M>
struct GCD : std::conditional<(N>M), GCD<N%M, M>, GCD<N, M%N>>::type
{ };