ariadne-cps / ariadne

C++ framework for rigorous computation on cyber-physical systems
http://www.ariadne-cps.org
GNU General Public License v3.0
28 stars 9 forks source link

Warnings related to inline functions used but not implemented #696

Closed lgeretti closed 1 year ago

lgeretti commented 1 year ago

Using gcc12, there are several warnings of the following kind:

/Users/lucageretti/Public/sources/ariadne-cps/ariadne/source/numeric/arithmetic.hpp:278:15: warning: inline function 'Ariadne::DeclareComparisonOperations<Ariadne::Approximation<Ariadne::Float<Ariadne::MultiplePrecision> >, Ariadne::ApproximateKleenean, Ariadne::ApproximateKleenean>::GT Ariadne::operator>(const Approximation<Float<MultiplePrecision> >&, const Approximation<Float<MultiplePrecision> >&)' used but never defined
  278 |     friend GT operator> (X const& x1, X const& x2);
      |               ^~~~~~~~
pietercollins commented 1 year ago

I think this may be a bug in g++. Here's some minimal code which generates the error:

template<class T> class DeclareOp { friend bool op(T const&); };
template<class T> class DefineOp {friend bool op(T const&) { return true; } };

class AClass : public DefineOp<AClass> { friend bool op(AClass const&); };
class AnotherClass : public DeclareOp<AClass> { };

int main() {
  op(AClass());
}

Note that any of the following changes cause the code to work: a) Removing friend bool op(AClass const&); from AClass. b) Removing the base of AnotherClass. c) Changing the base of AnotherClass to DefineOp<AClass>. d) Changing DefineOp to be non-templated, with a declaration friend bool op(AClass const&); Adding friend bool op(AClass const&); to AnotherClass results in failure even in cases a) and b) above, but cases c) and d) are still ok.

pietercollins commented 1 year ago

I will try to submit a defect report to GCC.

pietercollins commented 1 year ago

I think changing Declare to Define for the Approximation fallbacks in the LowerBound and UpperBound classes should fix the problem for now.

pietercollins commented 1 year ago

Simplified DefineXXX templates. Made declarations in FloatXxx classes DOXYGEN only.