Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
arnodu opened this issue Oct 12, 2022 · 6 comments · Fixed by #350

Comments

@arnodu
Copy link

arnodu commented Oct 12, 2022

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.

@edoardolombardi
Copy link
Member

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

andrea-iob added a commit that referenced this issue Oct 17, 2022
Fixes an error when compiling bitpit with libc++ (see issue #348).
@andrea-iob
Copy link
Member

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

@arnodu
Copy link
Author

arnodu commented Oct 17, 2022

#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

@arnodu
Copy link
Author

arnodu commented Oct 17, 2022

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

andrea-iob added a commit that referenced this issue Oct 18, 2022
Fixes an error when compiling bitpit with libc++ (see issue #348).
@andrea-iob
Copy link
Member

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

@arnodu
Copy link
Author

arnodu commented Oct 20, 2022

Yes, thanks it fixes the issue with get_git_head_revision

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants