optimad/bitpit

Compilation errors with llvm's libc++ : `binary_stream.tpp:72:18: error: reinterpret_cast <...> is not allowed`

Closed this issue · 6 comments

I have an issue when i compile bitpit with clang and it's own libc++.

I used bitpit's commit 7225403

Mainly :

~/bitpit/src/containers/binary_stream.tpp:72:18: error: reinterpret_cast from '__bit_iterator<std::__1::__bitset<1, 16>, true>' to 'const char *' is not allowed
  stream.write(reinterpret_cast<const char *>(&value), sizeof(T));
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~/bitpit/src/communications/communications_buffers.tpp:166:23: note: in instantiation of function template specialization 'operator<<<std::__1::__bit_const_reference<std::__1::__bitset<1, 16> > >' requested here
  buffer.getFront() << value;
           ^
~/bitpit/src/PABLO/ParaTree.cpp:5701:28: note: in instantiation of function template specialization 'operator<<<std::__1::__bit_const_reference<std::__1::__bitset<1, 16> > >' requested here
        sendBuffer << octant.m_info[Octant::INFO_AUX];

You need a cast to bool here to be compatible with the std::bitset::operator[] return value that may not be bool directly :

diff --git a/src/PABLO/ParaTree.cpp b/src/PABLO/ParaTree.cpp
index 1f603c3c..7a80a72f 100644
--- a/src/PABLO/ParaTree.cpp
+++ b/src/PABLO/ParaTree.cpp
@@ -5698,7 +5698,7 @@ namespace bitpit {
             for(std::size_t i = 0; i < nRankBorders; ++i){
                 const Octant &octant = m_octree.m_octants[rankBordersPerProc[i]];
                 sendBuffer << octant.getMarker();
-                sendBuffer << octant.m_info[Octant::INFO_AUX];
+               sendBuffer << (bool)octant.m_info[Octant::INFO_AUX];
             }
         }

Since i only use PABLO, there may be other locations in the rest of bitpit's codebase where this happens.

Hi @arnodu, thanks for the warning. We'll address the issue soon.

@arnodu Can you please check if #350 fixes the problem?

#350 seems to fix this particular issue but i had solve other issues to get the latest version working for my application :

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 347843abd..91e90079c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,7 @@
 #------------------------------------------------------------------------------------#
 cmake_minimum_required(VERSION 3.10)
 
-project("bitpit" CXX)
+project("bitpit" C CXX)
 
 #------------------------------------------------------------------------------------#
 # Variables visible to the user
diff --git a/external/git/cmake/GetGitRevisionDescription.cmake b/external/git/cmake/GetGitRevisionDescription.cmake
index 1f233308a..88d8d3cca 100644
--- a/external/git/cmake/GetGitRevisionDescription.cmake
+++ b/external/git/cmake/GetGitRevisionDescription.cmake
@@ -84,6 +84,9 @@ function(_git_find_closest_git_dir _start_dir _git_dir_var)
 endfunction()
 
 function(get_git_head_revision _refspecvar _hashvar)
+if(NOT GIT_FOUND)
+find_package(Git QUIET)
+endif()
     _git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR)
 
     if(${ARGC} GREATER 2})

rpavlik/cmake-modules#72

Du you want me to open separate issues for that or are you already aware of them?

@arnodu Can you please check if #353 fixes the problem with git?

Yes, thanks it fixes the issue with get_git_head_revision