https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96560
Bug ID: 96560
Summary: Substitution triggers compile-time error when it
shouldn't
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
This triggers the static_assert while it shouldn't, because DR 1227 says "The
substitution proceeds in lexical order and stops when a condition that causes
deduction to fail is encountered." Compiles with clang++/EDG.
template<bool, typename = void>
struct enable_if { };
template<typename T>
struct enable_if<true, T> {
using type = T;
};
template<class T>
struct hard_error {
static_assert(sizeof(T) == 0);
static inline constexpr bool value = true;
};
template<class T>
struct always_false {
static inline constexpr bool value = false;
};
template<class T>
int foo (int, typename enable_if<always_false<T>::value, int>::type = 0,
typename enable_if<hard_error<T>::value, int>::type = 0 )
{
return 0;
}
template<class T>
char const *foo (long)
{
return "";
}
int
main ()
{
char const *sz = foo<int>(0);
}