diff --git a/src/swig/nlopt-python.i b/src/swig/nlopt-python.i index b5cf55e1..30c7ccb0 100644 --- a/src/swig/nlopt-python.i +++ b/src/swig/nlopt-python.i @@ -124,8 +124,10 @@ __version__ = str(_nlopt.version_major())+'.'+str(_nlopt.version_minor())+'.'+st { npy_intp sz = $1.size(); $result = PyArray_SimpleNew(1, &sz, NPY_DOUBLE); - std::memcpy(array_data($result), $1.empty() ? NULL : &$1[0], - sizeof(double) * sz); + if (!$1.empty()) + { + std::memcpy(array_data($result), &$1[0], sizeof(double) * sz); + } } ////////////////////////////////////////////////////////////////////////////// diff --git a/test/cpp_functor.cxx b/test/cpp_functor.cxx index 47168368..0ec8e423 100644 --- a/test/cpp_functor.cxx +++ b/test/cpp_functor.cxx @@ -100,7 +100,7 @@ class LinearRegression { LinearRegression(QuadraticForm quadratic_form_) : quadratic_form(std::move(quadratic_form_)) {} - double operator()(unsigned n, const double* x, double* grad) const + double operator()(unsigned /*n*/, const double* x, double* grad) const { const double result = quadratic_form.compute_form(x); if (!!grad) {