https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97375
--- Comment #1 from Anders Granlund <anders.granlund.0 at gmail dot com> --- Here is another example of the same problem without using decltype(auto), so the problem seems to be more general: #include <iostream> #include <type_traits> template<const int I> void f1() { std::cout << std::is_const_v<decltype(I)> << std::endl; } template<typename T, T I> void f2() { std::cout << std::is_const_v<decltype(I)> << std::endl; } int main() { f1<0>(); // Outputs: 0 Ok f2<const int, 0>(); // Outputs: 1 Not ok. Should output 0 also. } Compiler explorer link for this example: https://godbolt.org/z/8ah1ax