Clang 16 changed to consider dereferencing a void* to be a warning-as-error, plus made this an error in SFINAE contexts, since this resulted in incorrect template instantiation. When doing so, the Clang 16 documentation was updated to reflect that this was likely to change again to a non-disablable error in the next version. As there has been no response to changing from a warning to an error, I believe this is a non-controversial change. This patch changes this to be an Error, consistent with the standard and other compilers. This was discussed in this RFC: https://discourse.llvm.org/t/rfc-can-we-stop-the-extension-to-allow-dereferencing-void-in-c/65708 Differential Revision: https://reviews.llvm.org/D150875
18 lines
557 B
C++
18 lines
557 B
C++
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
// Test instantiation of member functions of class templates defined out-of-line
|
|
template<typename T, typename U>
|
|
struct X0 {
|
|
void f(T *t, const U &u);
|
|
void f(T *);
|
|
};
|
|
|
|
template<typename T, typename U>
|
|
void X0<T, U>::f(T *t, const U &u) {
|
|
*t = u; // expected-error{{indirection not permitted on operand of type 'void *'}} expected-error{{not assignable}}
|
|
}
|
|
|
|
void test_f(X0<float, int> xfi, X0<void, int> xvi, float *fp, void *vp, int i) {
|
|
xfi.f(fp, i);
|
|
xvi.f(vp, i); // expected-note{{instantiation}}
|
|
}
|