From 64d2ef3e94ed9300518baaf382fc594f69accf91 Mon Sep 17 00:00:00 2001 From: wongalvis14 <45529524+wongalvis14@users.noreply.github.com> Date: Sun, 13 Jan 2019 21:37:42 +0800 Subject: [PATCH 1/2] Remove "init may be used uninitialized" warning --- ext/nmatrix/ruby_nmatrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/nmatrix/ruby_nmatrix.c b/ext/nmatrix/ruby_nmatrix.c index 8073c8c6..b7dbed95 100644 --- a/ext/nmatrix/ruby_nmatrix.c +++ b/ext/nmatrix/ruby_nmatrix.c @@ -1144,7 +1144,7 @@ static VALUE nm_init_new_version(int argc, VALUE* argv, VALUE self) { // Get the shape. size_t dim; size_t* shape = interpret_shape(shape_ary, &dim); - void* init; + void* init = NULL; void* v = NULL; size_t v_size = 0; From a31c37d4730fce37ffb8708c4d8f79748abe9c1c Mon Sep 17 00:00:00 2001 From: wongalvis14 <45529524+wongalvis14@users.noreply.github.com> Date: Sun, 13 Jan 2019 23:23:20 +0800 Subject: [PATCH 2/2] Add [[ noreturn ]] For compiler optimizations and remove compiler warnings --- ext/nmatrix/math.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/nmatrix/math.cpp b/ext/nmatrix/math.cpp index 880c1cd4..b288bafd 100644 --- a/ext/nmatrix/math.cpp +++ b/ext/nmatrix/math.cpp @@ -219,7 +219,7 @@ namespace nm { //we can't do det_exact on byte, because it will want to return a byte (unsigned), but determinants can be negative, even if all elements of the matrix are positive template <> - void det_exact_from_dense(const int M, const void* A_elements, const int lda, void* result_arg) { + [[ noreturn ]] void det_exact_from_dense(const int M, const void* A_elements, const int lda, void* result_arg) { rb_raise(nm_eDataTypeError, "cannot call det_exact on unsigned type"); } /* @@ -464,7 +464,7 @@ namespace nm { delete[] u; } - void raise_not_invertible_error() { + [[ noreturn ]] void raise_not_invertible_error() { rb_raise(nm_eNotInvertibleError, "matrix must have non-zero determinant to be invertible (not getting this error does not mean matrix is invertible if you're dealing with floating points)"); }