https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65708
Bug ID: 65708 Summary: Non-type template argument not visible causes substitution failure Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ldionne.2 at gmail dot com The following code produces an error on GCC trunk. The error says that there is no matching `f` to call: ------------------------------------------------------------------------------ template <typename T, T v> struct integral_constant { }; template <typename T, T v> decltype(~v) f(integral_constant<T, v>); int main() { f(integral_constant<int, 6>{}); } ------------------------------------------------------------------------------ Even more curious is that the problem goes away if I replace `decltype(~v)` by `decltype(v)` or even `decltype(+v)`. The exact error is: › ~/code/gcc5/bin/g++ ~/code/hana/test/worksheet.cpp -std=c++11 [...]: In function ‘int main()’: [...]: error: no matching function for call to ‘f(integral_constant<int, 6>)’ f(integral_constant<int, 6>{}); ^ [...]: note: candidate: template<class T, T v> decltype (~ v) f(integral_constant<T, v>) decltype(~v) f(integral_constant<T, v>); ^ [...]: note: template argument deduction/substitution failed: [...]: In substitution of ‘template<class T, T v> decltype (~ v) f(integral_constant<T, v>) [with T = int; T v = 6]’: [...]: required from here [...]: error: ‘v’ was not declared in this scope My GCC version: › ~/code/gcc5/bin/g++ --version g++ (GCC) 5.0.0 20150326 (experimental) Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.