[Bug c++/81134] C++ partial template specialization issue
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81134 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #1 from Jonathan Wakely --- 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 struct GCD { static const int value = std::conditional<(N>M), GCD, GCD>::type::value; }; Or like this: template struct GCD : std::conditional<(N>M), GCD, GCD>::type { };
[Bug c++/81134] C++ partial template specialization issue
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81134 --- Comment #2 from Manish --- Thanx Jonathan. Your explanation explains behavior. I wonder if standard has some preference dictated here?
[Bug c++/81134] C++ partial template specialization issue
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81134 --- Comment #3 from Jonathan Wakely --- The standard seems clear to me and GCC's behaviour is correct.
[Bug c++/81134] C++ partial template specialization issue
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81134 --- Comment #4 from Manish --- Which section in particular you are referring? I am looking at this doc, section 14.7 but couldn't find relevant point. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3690.pdf
[Bug c++/81134] C++ partial template specialization issue
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81134 --- Comment #5 from Jonathan Wakely --- To determine the type of the conditional expression it's necessary to know the types of both GCD::value and GCD::value, which requires instantiating both of GCD and GCD, which triggers the infinite recursion.