[Cbc] UndefinedBehaviorSanitizer error in OsiPresolvewhen casting Status

Petter Strandmark petter.strandmark at gmail.com
Sat Oct 21 11:09:28 EDT 2017


I am compiling and running Cbc with Clang’s UndefinedBehaviorSanitizer. I
have been able to fix several errors, but a more tricky one is the
following. This line sometimes incorrecly casts an enum:

<https://github.com/coin-or/Osi/blob/master/Osi/src/Osi/OsiPresolve.cpp#L505>
https://github.com/coin-or/Osi/blob/master/Osi/src/Osi/OsiPresolve.cpp#L505

The original enum looks like:
  /*! \brief Enum for status of various sorts

    Matches CoinWarmStartBasis::Status and adds superBasic. Most code that
    converts between CoinPrePostsolveMatrix::Status and
    CoinWarmStartBasis::Status will break if this correspondence is broken.

    superBasic is an unresolved problem: there's no analogue in
    CoinWarmStartBasis::Status.
  */
  enum Status {
    isFree = 0x00,
    basic = 0x01,
    atUpperBound = 0x02,
    atLowerBound = 0x03,
    superBasic = 0x04
  };

and the target enum looks like:

  enum Status {
    isFree = 0x00, ///< Nonbasic free variable
    basic = 0x01, ///< Basic variable
    atUpperBound = 0x02, ///< Nonbasic at upper bound
    atLowerBound = 0x03 ///< Nonbasic at lower bound
  };

UndefinedBehaviorSanitizer stops the execution because the status is
superBasic.

The question is, what is the correct course of action in that case?

Petter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20171021/bbf9ba3a/attachment.html>


More information about the Cbc mailing list