Gecode / gecode

Generic Constraint Development Environment
https://www.gecode.org
Other
283 stars 76 forks source link

Gecode does not build with -std=c++2a #110

Closed yurivict closed 3 years ago

yurivict commented 3 years ago

Describe the bug

clang-10 fails to compile gecode/driver.hh with -std=c++2a:

In file included from x.cpp:1:
In file included from /usr/local/include/gecode/driver.hh:37:
In file included from /usr/local/include/gecode/minimodel.hh:45:
In file included from /usr/local/include/gecode/kernel.hh:148:
/usr/local/include/gecode/kernel/gpi.hpp:189:47: error: no member named 'memory_order_seq_cst' in 'std::__1::memory_order'
    c->init(npid.fetch_add(std::memory_order::memory_order_seq_cst),gid);
                           ~~~~~~~~~~~~~~~~~~~^

The symbol std::memory_order::memory_order_seq_cst exists until c++20, but since c++20 is renamed into std::memory_order::seq_cst, see https://en.cppreference.com/w/cpp/atomic/memory_order

To Reproduce

Create a file x.cpp with the line #include <gecode/driver.hh>. Run c++ -std=c++2a x.cpp -I /usr/local/include/ -c

Gecode and Platform Configuration

Version 3.6.0 OS: FreeBSD 12.2 clang 10

yurivict commented 3 years ago

Partial fix: https://github.com/Gecode/gecode/pull/111

The other part of the problem is this warning:

In file included from /usr/local/include/gecode/driver.hh:37:
In file included from /usr/local/include/gecode/minimodel.hh:51:
In file included from /usr/local/include/gecode/float.hh:835:
/usr/local/include/gecode/float/val.hpp:296:18: warning: ISO C++20 considers use of overloaded operator '==' (with operand types 'const Gecode::FloatVal::FloatValImpType' (aka 'const interval<double, policies<save_state<Float::Rounding>, checking_strict<double> > >') and 'const Gecode::FloatVal::FloatValImpType') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator]
      return x.x == y.x;
             ~~~ ^  ~~~
/usr/local/include/boost/numeric/interval/interval.hpp:84:8: note: ambiguity is between a regular call to this operator and a call with the argument order reversed
  bool operator== (const interval_holder& r) const;
       ^

and this error:

In file included from /usr/local/include/gecode/driver.hh:37:
In file included from /usr/local/include/gecode/minimodel.hh:51:
In file included from /usr/local/include/gecode/float.hh:833:
/usr/local/include/gecode/float/val.hpp:319:18: error: use of overloaded operator '!=' is ambiguous (with operand types 'const Gecode::FloatVal::FloatValImpType' (aka 'const interval<double, policies<save_state<Float::Rounding>, checking_strict<double> > >') and 'const Gecode::FloatVal::FloatValImpType')
      return x.x != y.x;
             ~~~ ^  ~~~
/usr/local/include/gecode/third-party/boost/numeric/interval/interval.hpp:85:8: note: candidate function
  bool operator!= (const interval_holder& r) const;
       ^
/usr/local/include/gecode/third-party/boost/numeric/interval/interval.hpp:84:8: note: candidate function
  bool operator== (const interval_holder& r) const;
       ^
/usr/local/include/gecode/third-party/boost/numeric/interval/interval.hpp:84:8: note: candidate function (with reversed parameter order)
1 warning and 1 error generated.

I first thought that this was related to an outdated bundled boost library, but the same error/warning happen with the latest boost.

zayenz commented 3 years ago

Thanks for the fix i #111. As for the latter warning, there are some warnings still in Gecode that needs fixing. Will have to wait for the next release though.

zayenz commented 3 years ago

I'll close this issue for now as it compiles, leaving fixing warnings for later. Thanks for the report.

yurivict commented 3 years ago

There is still this c++2a error though:

In file included from /usr/local/include/gecode/minimodel.hh:51:
In file included from /usr/local/include/gecode/float.hh:833:
/usr/local/include/gecode/float/val.hpp:319:18: error: use of overloaded operator '!=' is ambiguous (with operand types 'const Gecode::FloatVal::FloatValImpType' (aka 'const interval<double, policies<save_state<Float::Rounding>, checking_strict<double> > >') and 'const Gecode::FloatVal::FloatValImpType')
      return x.x != y.x;
             ~~~ ^  ~~~
/usr/local/include/gecode/third-party/boost/numeric/interval/interval.hpp:85:8: note: candidate function
  bool operator!= (const interval_holder& r) const;
       ^
/usr/local/include/gecode/third-party/boost/numeric/interval/interval.hpp:84:8: note: candidate function
  bool operator== (const interval_holder& r) const;
       ^
/usr/local/include/gecode/third-party/boost/numeric/interval/interval.hpp:84:8: note: candidate function (with reversed parameter order)
zayenz commented 3 years ago

Ah, I thought it was warnings only. Re-opening.

yurivict commented 3 years ago

The remaining c++20 error appears to be bogus and clang-12 doesn't have it any more.