From 076c41ef3d245f6016b9c0b1b43086a0d5c5f942 Mon Sep 17 00:00:00 2001 From: Wang Xin Date: Wed, 26 Oct 2022 16:18:59 +0800 Subject: [PATCH] fix uninitialized, tautological-constant-out-of-range-compare and literal-conversion warning on macos (#47341) --- cmake/flags.cmake | 9 +++++++-- .../new_executor/workqueue/nonblocking_threadpool.h | 2 +- paddle/fluid/imperative/partial_grad_engine.cc | 3 ++- paddle/fluid/operators/interpolate_op.h | 2 +- paddle/phi/kernels/cpu/lstsq_kernel.cc | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 010cb6e08ee..4c26366c5ac 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -215,8 +215,13 @@ if(APPLE) endif() # On Mac OS X register class specifier is deprecated and will cause warning error on latest clang 10.0 set(COMMON_FLAGS - -Wno-deprecated-register -Werror=format - -Werror=inconsistent-missing-override -Werror=braced-scalar-init) + -Wno-deprecated-register + -Werror=format + -Werror=inconsistent-missing-override + -Werror=braced-scalar-init + -Werror=uninitialized + -Werror=tautological-constant-out-of-range-compare + -Werror=literal-conversion) endif() if(WITH_HETERPS AND WITH_PSLIB) diff --git a/paddle/fluid/framework/new_executor/workqueue/nonblocking_threadpool.h b/paddle/fluid/framework/new_executor/workqueue/nonblocking_threadpool.h index 930de3bdb2d..dd4438ba068 100644 --- a/paddle/fluid/framework/new_executor/workqueue/nonblocking_threadpool.h +++ b/paddle/fluid/framework/new_executor/workqueue/nonblocking_threadpool.h @@ -37,7 +37,7 @@ class ThreadPoolTempl { : env_(env), allow_spinning_(allow_spinning), always_spinning_(always_spinning), - global_steal_partition_(EncodePartition(0, num_threads_)), + global_steal_partition_(EncodePartition(0, num_threads)), blocked_(0), num_tasks_(0), done_(false), diff --git a/paddle/fluid/imperative/partial_grad_engine.cc b/paddle/fluid/imperative/partial_grad_engine.cc index b25bb2af0f8..471627e4ca5 100644 --- a/paddle/fluid/imperative/partial_grad_engine.cc +++ b/paddle/fluid/imperative/partial_grad_engine.cc @@ -328,7 +328,8 @@ static void FillConstantLike(const VariableWrapper &ref_var, // grad mission // we can't get data_type_ directly. We need to check if we can only use // default data_type for now. - if (ref_var.ForwardDataType() != -1) { + if (ref_var.ForwardDataType() != + static_cast(-1)) { dst_tensor->mutable_data( place, framework::TransToPhiDataType(ref_var.ForwardDataType())); } else { diff --git a/paddle/fluid/operators/interpolate_op.h b/paddle/fluid/operators/interpolate_op.h index dbd27f526bd..ff2d5236d78 100644 --- a/paddle/fluid/operators/interpolate_op.h +++ b/paddle/fluid/operators/interpolate_op.h @@ -502,7 +502,7 @@ HOSTDEVICE inline T cubic_convolution2(T x, T A) { template HOSTDEVICE inline void get_cubic_upsample_coefficients(T coeffs[4], T t) { - T A = -0.75; + T A = static_cast(-0.75); T x1 = t; coeffs[0] = cubic_convolution2(x1 + 1.0, A); diff --git a/paddle/phi/kernels/cpu/lstsq_kernel.cc b/paddle/phi/kernels/cpu/lstsq_kernel.cc index 5542c2ba6e7..6702ea78393 100644 --- a/paddle/phi/kernels/cpu/lstsq_kernel.cc +++ b/paddle/phi/kernels/cpu/lstsq_kernel.cc @@ -128,7 +128,7 @@ void LstsqKernel(const Context& dev_ctx, // run once the driver, first to get the optimal workspace size int lwork = -1; - T wkopt; + T wkopt = 0.0; ValueType rwkopt; int iwkopt = 0; -- GitLab