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

Include conflict between boost/type_traits and boost/histogram #462 #290

Closed
ralfulrich opened this issue Oct 12, 2020 · 7 comments
Closed

Comments

@ralfulrich
Copy link

The following minimal program

#include <boost/type_traits.hpp>
#include <boost/histogram.hpp>    // reversion include order --> compiles !

int main() {
  return 0;
}

fails to compile with

In file included from ./boost/histogram/indexed.hpp:12:0,
                 from ./boost/histogram/algorithm/empty.hpp:11,
                 from ./boost/histogram/algorithm.hpp:15,
                 from ./boost/histogram.hpp:27,
                 from /corsika/test/test.cc:4:
./boost/histogram/axis/traits.hpp:411:41: error: return type specified for deduction guide
 constexpr unsigned rank(const Axis& axis) {
                                         ^
./boost/histogram/axis/traits.hpp:411:11: error: decl-specifier in declaration of deduction guide
 constexpr unsigned rank(const Axis& axis) {
           ^~~~~~~~
./boost/histogram/axis/traits.hpp:411:1: error: decl-specifier in declaration of deduction guide
 constexpr unsigned rank(const Axis& axis) {
 ^~~~~~~~~
./boost/histogram/axis/traits.hpp:411:41: error: 'signed' or 'unsigned' invalid for '__dguide_rank'
 constexpr unsigned rank(const Axis& axis) {
                                         ^
./boost/histogram/axis/traits.hpp:411:20: error: deduction guide for 'boost::rank<T>' must have trailing return type
 constexpr unsigned rank(const Axis& axis) {
                    ^~~~
In file included from ./boost/type_traits.hpp:145:0,
                 from /corsika/test/test.cc:2:
./boost/type_traits/rank.hpp:82:27: note: 'template<class T> struct boost::rank' declared here
 template <class T> struct rank : public integral_constant<std::size_t, (::boost::detail::rank_imp<T, 0>::value)>{};
                           ^~~~
In file included from ./boost/histogram/indexed.hpp:12:0,
                 from ./boost/histogram/algorithm/empty.hpp:11,
                 from ./boost/histogram/algorithm.hpp:15,
                 from ./boost/histogram.hpp:27,
                 from /corsika/test/test.cc:4:
./boost/histogram/axis/traits.hpp:411:20: error: deduction guide 'constexpr boost::histogram::axis::traits::rank(const Axis&)-> rank' must not have a function body
 constexpr unsigned rank(const Axis& axis) {
                    ^~~~
./boost/histogram/axis/traits.hpp:421:47: error: return type specified for deduction guide
 unsigned rank(const axis::variant<Ts...>& axis) {
                                               ^
./boost/histogram/axis/traits.hpp:421:1: error: decl-specifier in declaration of deduction guide
 unsigned rank(const axis::variant<Ts...>& axis) {
 ^~~~~~~~
./boost/histogram/axis/traits.hpp:421:47: error: 'signed' or 'unsigned' invalid for '__dguide_rank'
 unsigned rank(const axis::variant<Ts...>& axis) {
                                               ^
./boost/histogram/axis/traits.hpp:421:10: error: deduction guide for 'boost::rank<T>' must have trailing return type
 unsigned rank(const axis::variant<Ts...>& axis) {
          ^~~~
In file included from ./boost/type_traits.hpp:145:0,
                 from /corsika/test/test.cc:2:
./boost/type_traits/rank.hpp:82:27: note: 'template<class T> struct boost::rank' declared here
 template <class T> struct rank : public integral_constant<std::size_t, (::boost::detail::rank_imp<T, 0>::value)>{};
                           ^~~~
In file included from ./boost/histogram/indexed.hpp:12:0,
                 from ./boost/histogram/algorithm/empty.hpp:11,
                 from ./boost/histogram/algorithm.hpp:15,
                 from ./boost/histogram.hpp:27,
                 from /corsika/test/test.cc:4:
./boost/histogram/axis/traits.hpp:421:10: error: deduction guide 'boost::histogram::axis::traits::rank(const boost::histogram::axis::variant<Ts ...>&)-> rank' must not have a function body
 unsigned rank(const axis::variant<Ts...>& axis) {
          ^~~~
In file included from ./boost/histogram/histogram.hpp:14:0,
                 from ./boost/histogram/algorithm/project.hpp:15,
                 from ./boost/histogram/algorithm.hpp:16,
                 from ./boost/histogram.hpp:27,
                 from /corsika/test/test.cc:4:
./boost/histogram/detail/fill.hpp: In function 'typename S::iterator boost::histogram::detail::fill(std::true_type, ArgTraits, std::size_t, S&, A&, const Args&)':
./boost/histogram/detail/fill.hpp:319:26: error: 'rank' is not a member of 'boost::histogram::axis::traits'
            axis::traits::rank(axis_get<0>(axes)) == ArgTraits::nargs::value)
                          ^~~~
./boost/histogram/detail/fill.hpp:319:26: note: suggested alternatives:
In file included from /usr/include/c++/7/bits/move.h:54:0,
                 from /usr/include/c++/7/bits/stl_pair.h:59,
                 from /usr/include/c++/7/utility:70,
                 from ./boost/type_traits/detail/has_binary_operator.hpp:41,
                 from ./boost/type_traits/has_bit_and.hpp:43,
                 from ./boost/type_traits.hpp:36,
                 from /corsika/test/test.cc:2:
/usr/include/c++/7/type_traits:1468:12: note:   'std::rank'
     struct rank
            ^~~~
In file included from ./boost/type_traits.hpp:145:0,
                 from /corsika/test/test.cc:2:
./boost/type_traits/rank.hpp:82:27: note:   'boost::rank'
 template <class T> struct rank : public integral_constant<std::size_t, (::boost::detail::rank_imp<T, 0>::value)>{};
                           ^~~~

on an ubuntu 18.04 docker container with gcc7.5.0 and boost-headers 1.74

To reproduce, e.g. sudo docker run -v $PWD:/corsika -it corsika/devel:u-18.04 /bin/bash and then compile the above mini program, while putting the boost headers right there.

@mreininghaus
Copy link

The error occurs with -std=c++17, however not with -std=c++14 (both g++ (GCC) 9.2.0).

@HDembinski
Copy link
Collaborator

HDembinski commented Oct 30, 2020

Thank you for reporting this bug. There is a name clash, somewhere rank is used without being properly qualified by a namespace.

Link to reproduce:
https://godbolt.org/z/oK4866

Only gcc seems to be affected and only versions starting with 7.1

@HDembinski
Copy link
Collaborator

It looks like a bug in gcc. A workaround is to replace line 82 in boost/type_traits/rank.hpp with

template <class T> using rank = integral_constant<std::size_t, (::boost::detail::rank_imp<T, 0>::value)>;

@HDembinski
Copy link
Collaborator

HDembinski commented Oct 30, 2020

Minimal example to reproduce the problem without including boost at all:

https://godbolt.org/z/hrcYao

msvc is OK, clang is OK, gcc fails

@HDembinski
Copy link
Collaborator

Simple workarounds for the gcc bug were found by Thomas Ferrand and John Maddock. Those will be applied tomorrow. Next release 1.75 will have the fix for this.

@HDembinski
Copy link
Collaborator

@HDembinski
Copy link
Collaborator

fixed in develop

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

No branches or pull requests

3 participants