[Soplex] Compilation error in soplex include file when building scip

Peter Notebaert mail at peno.be
Mon Jun 19 22:03:12 CEST 2023


When I try to compile scip, I get a compilation error in a soplex include
file.

I compile under windows with cmake and it uses Microsoft Visual Studio 17
2022

First I had to build soplex. I used following commands for that:

cmake -Bbuild -H.
cmake --build build --config Release

This worked find and generated the soplex binaries.

Then I use the following command to build scip:

cmake -Bbuild -H. -DSOPLEX_DIR=..\soplex\build -DZLIB=off -DREADLINE=off
-DGMP=off -DPAPILO=off -DZIMPL=off -DIPOPT=off

Which works fine. Then I use the following command to build:

cmake --build build --config Release

At a certain point it gives:

C:\git\soplex\src\soplex/ssvectorbase.h(135,1): error C2445: result type of
conditional expression is ambiguous: types 'R' and 'soplex::Real' can be
converted to multiple common types [C:\git\scip\build\src\libscip.vcxproj]
          with
          [
              R=Rational
          ]
C:\git\soplex\src\soplex/ssvectorbase.h(135,1): message : could be 'R'
[C:\git\scip\build\src\libscip.vcxproj]
          with
          [
              R=Rational
          ]
C:\git\soplex\src\soplex/ssvectorbase.h(135,1): message : or
'soplex::Real' [C:\git\scip\build\src\libscip.vcxproj]
C:\git\soplex\src\soplex/ssvectorbase.h(133,1): message : while compiling
class template member function 'R soplex::SSVectorBase<R>::getEpsilon(void)
const' [C:\git\scip\build\src\libscip.vcxproj]
          with
          [
              R=Rational
          ]
C:\git\soplex\src\soplex/ssvectorbase.h(861,16): message : see reference to
function template instantiation 'R
soplex::SSVectorBase<R>::getEpsilon(void) const' being compiled
[C:\git\scip\build\src\libscip.vcxproj]
          with
          [
              R=Rational
          ]
C:\git\soplex\src\soplex/basevectors.h(898,55): message : see reference to
class template instantiation 'soplex::SSVectorBase<R>' being compiled
[C:\git\scip\build\src\libscip.vcxproj]
          with
          [
              R=Rational
          ]

It's about this code:

   R getEpsilon() const
   {
      assert(this->_tolerances != nullptr);
      return this->_tolerances == nullptr ? R(0) :
this->tolerances()->epsilon();
   }

And specifically

return this->_tolerances == nullptr ? R(0) : this->tolerances()->epsilon();

I guess most compilers accept an implicit cast from
this->tolerances()->epsilon() which is a soplex::Real and type R.

To make it compile, I changed the line to:

return this->_tolerances == nullptr ? R(0) :
(R)this->tolerances()->epsilon();

And then everything compiles fine.

My C++ knowledge is very limited (I never got further than C) so I am also
not 100% sure is this is the correct solution for this problem.

It would be great if the code was changed to solve this ambiguity.

Thank you,

Peter Notebaert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.zib.de/pipermail/soplex/attachments/20230619/f1a7cf00/attachment.html>


More information about the SoPlex mailing list