https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104980
Bug ID: 104980
Summary: Bad error on variable template instantiation failure
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: Darrell.Wright at gmail dot com
Target Milestone: ---
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;
| ^~~~~~~~~~~
Whereas clang gives both the definition and call site in its output:
using enable_if_t = typename enable_if<_Cond, _Tp>::type;
^~~~~
<source>:12:18: note: in instantiation of template type alias 'enable_if_t'
requested here
inline constexpr DELETED_VARIABLE is_foo = deleted;
^
<source>:9:31: note: expanded from macro 'DELETED_VARIABLE'
#define DELETED_VARIABLE std::enable_if_t<dependent_false_v<T>, deleted_t>
^
<source>:18:10: note: in instantiation of variable template specialization
'is_foo' requested here
auto b = is_foo<bool>;
This is more desirable as one can see what is going on. Would it be possible
to output better information so that a developer can more clearly see what
failed?