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

Compile error with GCC 11 #131

Open
susilehtola opened this issue Nov 29, 2021 · 10 comments
Open

Compile error with GCC 11 #131

susilehtola opened this issue Nov 29, 2021 · 10 comments

Comments

@susilehtola
Copy link

Trying to compile the current master branch with gcc 11.2.1 in Fedora 35 leads to

mpicxx -O3 -fopenmp -Wall  -D_POSIX_C_SOURCE=200112L -D__STDC_LIMIT_MACROS -DFTN_UNDERSCORE=1 -DUSE_LAPACK   -c idx_tensor.cxx -o /home/work/aquarius.susi/src/external/ctf/obj/idx_tensor.o
In file included from /usr/include/c++/11/map:60,
                 from /usr/include/openmpi-x86_64/openmpi/ompi/mpi/cxx/mpicxx.h:42,
                 from /usr/include/openmpi-x86_64/mpi.h:2887,
                 from common.h:18,
                 from idx_tensor.cxx:3:
/usr/include/c++/11/bits/stl_tree.h: In instantiation of ‘static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = CTF::Idx_Tensor*; _Val = CTF::Idx_Tensor*; _KeyOfValue = std::_Identity<CTF::Idx_Tensor*>; _Compare = CTF_int::tensor_name_less; _Alloc = std::allocator<CTF::Idx_Tensor*>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<CTF::Idx_Tensor*>*]’:
/usr/include/c++/11/bits/stl_tree.h:2069:47:   required from ‘std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = CTF::Idx_Tensor*; _Val = CTF::Idx_Tensor*; _KeyOfValue = std::_Identity<CTF::Idx_Tensor*>; _Compare = CTF_int::tensor_name_less; _Alloc = std::allocator<CTF::Idx_Tensor*>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = CTF::Idx_Tensor*]’
/usr/include/c++/11/bits/stl_tree.h:2122:4:   required from ‘std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = CTF::Idx_Tensor*; _Key = CTF::Idx_Tensor*; _Val = CTF::Idx_Tensor*; _KeyOfValue = std::_Identity<CTF::Idx_Tensor*>; _Compare = CTF_int::tensor_name_less; _Alloc = std::allocator<CTF::Idx_Tensor*>]’
/usr/include/c++/11/bits/stl_set.h:521:25:   required from ‘std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::value_type&&) [with _Key = CTF::Idx_Tensor*; _Compare = CTF_int::tensor_name_less; _Alloc = std::allocator<CTF::Idx_Tensor*>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<CTF::Idx_Tensor*, CTF::Idx_Tensor*, std::_Identity<CTF::Idx_Tensor*>, CTF_int::tensor_name_less, std::allocator<CTF::Idx_Tensor*> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<CTF::Idx_Tensor*>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<CTF::Idx_Tensor*>, CTF::Idx_Tensor*>::rebind<CTF::Idx_Tensor*>; typename _Alloc::value_type = CTF::Idx_Tensor*; std::set<_Key, _Compare, _Alloc>::value_type = CTF::Idx_Tensor*]’
idx_tensor.cxx:325:23:   required from here
/usr/include/c++/11/bits/stl_tree.h:770:15: error: static assertion failed: comparison object must be invocable as const
  770 |               is_invocable_v<const _Compare&, const _Key&, const _Key&>,
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/stl_tree.h:770:15: note: ‘std::is_invocable_v<const CTF_int::tensor_name_less&, CTF::Idx_Tensor* const&, CTF::Idx_Tensor* const&>’ evaluates to false
@covitof
Copy link

covitof commented Dec 3, 2021

I have run into the same problem. I'm not entirely sure what the problem is and what it is related to, but I assumed it was an issue with newer versions of the compiler and tried 'CXXFLAGS=-std=c++14' which solved the problem for me.

@susilehtola
Copy link
Author

Right. The problem is that configure does not set the C++ standard...

@susilehtola
Copy link
Author

Migrating to CMake would probably make a lot of things easier..

@raghavendrak
Copy link
Collaborator

The tensor_name_less::operator() should be const (in interface/term.h and interface/term.cxx). Comparison operators should be constant, and I think they are being enforced in this compiler. Will submit a pull request to fix this.

@jeffhammond
Copy link
Collaborator

Switching to CMake when the problem requires a 1-line fix for each compiler type (and almost all of them use GCC-compatible -std= anyways) is killing a mosquito with nuclear weapons.

I will write the trivial fix in configure. CMake is going to create an endless nightmare of maintenance.

@susilehtola
Copy link
Author

susilehtola commented Feb 10, 2022

Switching to CMake when the problem requires a 1-line fix for each compiler type (and almost all of them use GCC-compatible -std= anyways) is killing a mosquito with nuclear weapons.

But hey, at least the bug is dead!
[Also, Finland used to host world championships of mosquito swatting.]

@raghavendrak
Copy link
Collaborator

@susilehtola Was wondering if the pull request mentioned here fixed the issue for c++11?

@susilehtola
Copy link
Author

@raghavendrak I tried, but the PR doesn't give a clean patch

@raghavendrak
Copy link
Collaborator

@susilehtola sorry there was an issue in my fork. Have fixed the same. Can you try it now?

@susilehtola
Copy link
Author

@susilehtola sorry there was an issue in my fork. Have fixed the same. Can you try it now?

fix confirmed

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

No branches or pull requests

4 participants