diff --git a/CMakeLists.txt b/CMakeLists.txt index 3dc01b5925e..1c5aca027b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -642,6 +642,10 @@ if(NOT MSVC) if(HAS_WERROR_FORMAT) string(APPEND CMAKE_CXX_FLAGS " -Werror=format") endif() + check_cxx_compiler_flag("-Werror=cast-function-type" HAS_WERROR_CAST_FUNCTION_TYPE) + if(HAS_WERROR_CAST_FUNCTION_TYPE) + string(APPEND CMAKE_CXX_FLAGS " -Werror=cast-function-type") + endif() endif() if(USE_ASAN) diff --git a/torch/csrc/autograd/python_variable.cpp b/torch/csrc/autograd/python_variable.cpp index 0ff8938664f..d370f81f6c7 100644 --- a/torch/csrc/autograd/python_variable.cpp +++ b/torch/csrc/autograd/python_variable.cpp @@ -425,7 +425,7 @@ PyObject *THPVariable_get_names(PyObject *self, void *unused) END_HANDLE_TH_ERRORS } -int THPVariable_set_names(PyObject *self, PyObject *names) { +int THPVariable_set_names(PyObject *self, PyObject *names, void *unused) { HANDLE_TH_ERRORS if (check_has_torch_function(self)) { return handle_torch_function_setter((THPVariable*)self, "names", names);