https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80544
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- And also reinterpret_cast: template<typename T> struct check { }; template<typename T> struct check<const T>; template<typename T> check<T> f(T&&) { return {}; } template<typename T> T val() { return {}; } int main() { int i; f(static_cast<int* const>(&i)); f(const_cast<int* const>(&i)); f(reinterpret_cast<long* const>(&i)); } v.cc: In function ‘int main()’: v.cc:10:32: error: invalid use of incomplete type ‘struct check<int* const>’ f(static_cast<int* const>(&i)); ^ v.cc:1:29: note: declaration of ‘struct check<int* const>’ template<typename T> struct check { }; ^~~~~ v.cc:11:31: error: invalid use of incomplete type ‘struct check<int* const>’ f(const_cast<int* const>(&i)); ^ v.cc:1:29: note: declaration of ‘struct check<int* const>’ template<typename T> struct check { }; ^~~~~ v.cc:12:38: error: invalid use of incomplete type ‘struct check<long int* const>’ f(reinterpret_cast<long* const>(&i)); ^ v.cc:1:29: note: declaration of ‘struct check<long int* const>’ template<typename T> struct check { }; ^~~~~ v.cc: In instantiation of ‘check<T> f(T&&) [with T = int* const]’: v.cc:10:32: required from here v.cc:4:31: error: return type ‘struct check<int* const>’ is incomplete template<typename T> check<T> f(T&&) { return {}; } ^ v.cc: In instantiation of ‘check<T> f(T&&) [with T = long int* const]’: v.cc:12:38: required from here v.cc:4:31: error: return type ‘struct check<long int* const>’ is incomplete