https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87512
Bug ID: 87512 Summary: Error: the type ‘const auto’ of ‘constexpr’ variable is not literal Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: officesamurai at gmail dot com Target Milestone: --- Created attachment 44779 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44779&action=edit Preprocessed source The following code fails to compile: == #include <type_traits> template <typename T> inline constexpr auto IsPtr = std::is_pointer<T>::value; class Foo; class Bar; template <typename T1, typename T2> void foo(T1, T2); template <typename T> std::enable_if_t<IsPtr<T>> foo(T, Foo); template <> void foo<Bar>(Bar, Bar); == The error: == $ g++-8.2.0 -c -std=c++17 test.cpp test.cpp: In instantiation of ‘constexpr const auto IsPtr<Bar>’: test.cpp:13:18: required by substitution of ‘template<class T> std::enable_if_t<IsPtr<T> > foo(T, Foo) [with T = Bar]’ test.cpp:16:23: required from here test.cpp:4:23: error: the type ‘const auto’ of ‘constexpr’ variable ‘IsPtr<Bar>’ is not literal inline constexpr auto IsPtr = std::is_pointer<T>::value; ^~~~~ test.cpp:4:23: error: ‘const auto IsPtr<Bar>’ has incomplete type == GCC version: == $ g++-8.2.0 -v Using built-in specs. COLLECT_GCC=g++-8.2.0 COLLECT_LTO_WRAPPER=/home/brd/soft/gcc-8.2.0/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ./configure --prefix=/home/brd/soft/gcc-8.2.0 Thread model: posix gcc version 8.2.0 (GCC) == The preprocessed source is attached. P.S. 1) Clang is able to compile it. 2) Changing "auto" to "bool" in the definition of IsPtr fixes the error.