[Bug c++/104691] SFINAE does not disable static_assert
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Feb 25 17:38:41 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104691
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:
template<typename T>
typename T::foo
f(T) { }
template<typename T>
typename T::bar
f(T) { static_assert(false, ""); }
struct X { using foo = void; };
int main()
{
X x;
f(x);
}
All compilers reject this code.
Something as simple as static_assert(sizeof(T) != 0, ""); can be used to make
it dependent, and then it will only fail when the template is instantiated.
More information about the Gcc-bugs
mailing list