https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84489
Bug ID: 84489 Summary: Non-type template parameter dependency Product: gcc Version: 7.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vince.rev at gmail dot com Target Milestone: --- Created attachment 43475 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43475&action=edit Example code of the bug Consider the following code in C++11. ========================================================= #include <iostream> template <class T = int, T N = T(), T B = (N >> 1)> constexpr T f0() {return 0;} template <class T = int, T N = T(), bool B = (N >> 1)> constexpr T f1() {return 0;} int main() { f0(); // No bug f1(); // Bug here return 0; } ========================================================= It compiles well under g++ 4.7, 4.8, 4.9, 5.X but fails to compile under 6.X and 7.X. It also compiles well under clang. The returned error is: ========================================================= gcc_bug_template_bool.cpp: In function 'int main()': gcc_bug_template_bool.cpp:12:8: error: no matching function for call to 'f1()' f1(); ^ gcc_bug_template_bool.cpp:7:13: note: candidate: template<class T, T N, bool B> constexpr T f1() constexpr T f1() {return 0;} ^~ gcc_bug_template_bool.cpp:7:13: note: template argument deduction/substitution failed: gcc_bug_template_bool.cpp:6:49: error: invalid use of template type parameter 'T' template <class T = int, T N = T(), bool B = (N >> 1)> ~~~^~~~~ gcc_bug_template_bool.cpp:6:53: error: could not convert template argument '<expression error>' from '<type error>' to 'bool' template <class T = int, T N = T(), bool B = (N >> 1)> =========================================================