From 6cd6d31d5bf9ca490898a30c26eacc68e6819f12 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Wed, 20 Jun 2018 07:25:58 +0100 Subject: [PATCH 1/2] Unit test framwork: use references when catching exceptions GCC 8 warns about catching by value; this was not caught in the earlier cleanup as it did not include unit tests. --- jbmc/unit/java_bytecode/java_types/erase_type_arguments.cpp | 2 +- unit/testing-utils/catch.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jbmc/unit/java_bytecode/java_types/erase_type_arguments.cpp b/jbmc/unit/java_bytecode/java_types/erase_type_arguments.cpp index 225f2d8c4c3..fc0a02c561b 100644 --- a/jbmc/unit/java_bytecode/java_types/erase_type_arguments.cpp +++ b/jbmc/unit/java_bytecode/java_types/erase_type_arguments.cpp @@ -63,6 +63,6 @@ SCENARIO("erase_type_arguments", "[core][java_types]") REQUIRE_THROWS_AS( erase_type_arguments( "testClassName"), - unsupported_java_class_signature_exceptiont &); + unsupported_java_class_signature_exceptiont); } } diff --git a/unit/testing-utils/catch.hpp b/unit/testing-utils/catch.hpp index 45328b8545c..fa9110ca0ce 100644 --- a/unit/testing-utils/catch.hpp +++ b/unit/testing-utils/catch.hpp @@ -2245,7 +2245,7 @@ namespace Catch { static_cast(expr); \ __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \ } \ - catch( exceptionType ) { \ + catch( const exceptionType & ) { \ __catchResult.captureResult( Catch::ResultWas::Ok ); \ } \ catch( ... ) { \ From 961b29ad654ded2c10e54ac4d37708b780892707 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Wed, 20 Jun 2018 07:32:22 +0100 Subject: [PATCH 2/2] Silence GCC 8's warning about using realloc/memmove on non-POD --- src/util/small_map.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/util/small_map.h b/src/util/small_map.h index 61537c19d3b..c8845dfb234 100644 --- a/src/util/small_map.h +++ b/src/util/small_map.h @@ -146,7 +146,10 @@ class small_mapt if(n == 0) return nullptr; - T *mem = (T *)realloc(ptr, sizeof(T) * n); + // explicitly cast to char * as GCC 8 warns about not using new/delete for + // class sharing_node_innert, + // std::equal_to > + T *mem = (T *)realloc((char *)ptr, sizeof(T) * n); if(!mem) throw std::bad_alloc(); @@ -486,7 +489,11 @@ class small_mapt std::size_t n = size(); if(ii < n - 1) { - memmove(p + ii, p + ii + 1, sizeof(T) * (n - ii - 1)); + // explicitly cast to char * as GCC 8 warns about not using new/delete + // for + // class sharing_node_innert, + // std::equal_to > + memmove((char *)(p + ii), p + ii + 1, sizeof(T) * (n - ii - 1)); } p = allocate(p, n - 1);