https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104980
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-03-18
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Darrell Wright from comment #0)
> The error generated when a variable template instantiation failure happens
> is unhelpful. Clang provides more context in their error output.
>
> With the following code
> https://gcc.godbolt.org/z/KoYf7rhEq
> #include <type_traits>
>
> template <typename T>
> inline constexpr bool dependent_false_v = false;
>
> struct deleted_t{};
> inline constexpr auto deleted = deleted_t{};
>
> #define DELETED_VARIABLE std::enable_if_t<dependent_false_v<T>, deleted_t>
>
> template <typename T>
> inline constexpr DELETED_VARIABLE is_foo = deleted;
>
> template <>
> inline constexpr bool is_foo<int> = true;
>
> auto a = is_foo<int>;
> auto b = is_foo<bool>;
>
> gcc outputs only:
> 2614 | using enable_if_t = typename enable_if<_Cond, _Tp>::type;
> | ^~~~~~~~~~~
And the location where enable_if_t is used:
<source>:4:62: required from here
But you're right it doesn't show where the variable template is instantiated.
Reduced to get rid of the irrelevant parts:
#include <type_traits>
template <typename T>
inline constexpr std::enable_if_t<std::is_same_v<T, int>, T> is_foo = {};
template <>
inline constexpr bool is_foo<int> = true;
auto a = is_foo<int>;
auto b = is_foo<bool>;
GCC:
In file included from 104980.C:1:
/home/jwakely/gcc/12/include/c++/12.0.1/type_traits: In substitution of
'template<bool _Cond, class _Tp> using enable_if_t = typename
std::enable_if::type [with bool _Cond = false; _Tp = bool]':
104980.C:4:62: required from here
/home/jwakely/gcc/12/include/c++/12.0.1/type_traits:2614:11: error: no type
named 'type' in 'struct std::enable_if<false, bool>'
2614 | using enable_if_t = typename enable_if<_Cond, _Tp>::type;
| ^~~~~~~~~~~
Clang:
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/type_traits:2585:44:
error: no type named 'type' in 'std::enable_if<false, bool>'; 'enable_if'
cannot be used to disable this declaration
using enable_if_t = typename enable_if<_Cond, _Tp>::type;
^~~~~
104980.C:4:23: note: in instantiation of template type alias 'enable_if_t'
requested here
inline constexpr std::enable_if_t<std::is_same_v<T, int>, T> is_foo = {};
^
104980.C:10:10: note: in instantiation of variable template specialization
'is_foo' requested here
auto b = is_foo<bool>;
^
1 error generated.
EDG:
"/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/type_traits",
line 2585: error: class "std::enable_if<false, bool>" has no member
"type"
using enable_if_t = typename enable_if<_Cond, _Tp>::type;
^
detected during:
instantiation of type "std::enable_if_t<false, bool>" at line 4 of
"104980.C"
instantiation of "const std::enable_if_t<std::is_same_v, T> is_foo
[with T=bool]" at line 10 of "104980.C"
1 error detected in the compilation of "104980.C".