From 03d198b2512c20a0413fee129c004956eeb2a9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Stegh=C3=B6fer?= Date: Sat, 4 Oct 2014 22:00:52 +0200 Subject: [PATCH 1/2] Fix clang (< 3.5) compilation by avoiding VLAs The length of the array defined locally in array::_get_val cannot be detected to be constant by a standard C++ compiler. GCC's g++ accepts the code anyway because of its ample support for variable-length arrays (VLAs). Clang doesn't support VLAs for non-POD (Plain Old Type) types. Starting from version 3.5, however, it is able to detect the constant nature of the value used (using non-standard language features, too) and therefore doesn't need LVAs here. However, clang compilers before 3.5 as well as compilers that support only pure C++ need this patching. --- include/jellyfish/large_hash_array.hpp | 2 +- include/jellyfish/simple_circular_buffer.hpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/jellyfish/large_hash_array.hpp b/include/jellyfish/large_hash_array.hpp index 74f10003..2a49c9f5 100644 --- a/include/jellyfish/large_hash_array.hpp +++ b/include/jellyfish/large_hash_array.hpp @@ -444,7 +444,7 @@ class array_base { bool get_key_id(const key_type& key, size_t* id, key_type& tmp_key, const word** w, const offset_t** o, const size_t oid) const { // This static_assert makes clang++ happy static_assert(std::is_pod::value, "prefetch_info must be a POD"); - prefetch_info info_ary[prefetch_buffer::capacity()]; + prefetch_info info_ary[prefetch_buffer::capacityConstant]; prefetch_buffer buffer(info_ary); warm_up_cache(buffer, oid); diff --git a/include/jellyfish/simple_circular_buffer.hpp b/include/jellyfish/simple_circular_buffer.hpp index 08afcc3e..16cc2ba9 100644 --- a/include/jellyfish/simple_circular_buffer.hpp +++ b/include/jellyfish/simple_circular_buffer.hpp @@ -106,6 +106,7 @@ namespace jellyfish { class pre_alloc : public base > { typedef base > super; public: + static const int capacityConstant = capa; explicit pre_alloc(T* data) : super(data) { } static int capacity() { return capa; } }; From 780f2ec462a077d521580d8b19f16fb30b138368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Stegh=C3=B6fer?= Date: Sat, 4 Oct 2014 22:10:59 +0200 Subject: [PATCH 2/2] Fix clang compilation by removing "register" keywords The clang compiler warns about the "register" keyword being deprecated in C++11. As the Jellyfish build system treats warnings as errors, this breaks the build with clang. I suggest to remove the keyword instead of silencing the warning because most modern compilers (e.g. the recent versions of GCC, clang and Visual Studio) ignore the keyword in their optimization algorithms anyway. --- include/jellyfish/rectangular_binary_matrix.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/jellyfish/rectangular_binary_matrix.hpp b/include/jellyfish/rectangular_binary_matrix.hpp index d545b65f..75ab7948 100644 --- a/include/jellyfish/rectangular_binary_matrix.hpp +++ b/include/jellyfish/rectangular_binary_matrix.hpp @@ -261,8 +261,8 @@ namespace jellyfish { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wuninitialized" #endif - register xmm_t acc = acc ^ acc; // Set acc to 0 - register xmm_t load = load ^ load; + xmm_t acc = acc ^ acc; // Set acc to 0 + xmm_t load = load ^ load; #ifdef __clang__ #pragma clang diagnostic pop #endif