coin-or / coin-or/CoinUtils

Compile issues because CoinByteArray is a pointer, no integer

Open
#131 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
53
Forks
47
PR merge metrics
No merged PRs in 30d

Description

I get errors with clang 10 like:

In file included from /local/hdd/cullmann/git/3rdparty/cbc/src/CoinUtils/src/CoinPackedVector.cpp:13:
/local/hdd/cullmann/git/3rdparty/cbc/src/CoinUtils/src/CoinHelperFunctions.hpp: In function ‘void CoinMemcpyN(const T*, CoinByteArray, T*)’:
/local/hdd/cullmann/git/3rdparty/cbc/src/CoinUtils/src/CoinHelperFunctions.hpp:331:57: error: invalid operands of types ‘const CoinByteArray’ {aka ‘int* const’} and ‘int’ to binary ‘operator>>’
331 | for (CoinBigIndex n = static_cast(size>>3); n > 0; --n, from += 8, to += 8) {
| ~~~~^~~
| | |
| | int
| const CoinByteArray {aka int* const}
/local/hdd/cullmann/git/3rdparty/cbc/src/CoinUtils/src/CoinHelperFunctions.hpp:341:16: error: invalid operands of types ‘const CoinByteArray’ {aka ‘int* const’} and ‘int’ to binary ‘operator%’
341 | switch (size % 8) {
| ~~~~ ^ ~
| | |
| | int
| const CoinByteArray {aka int* const}

I would assume you want to use a integer type of the right size instead.

Wouldn't size_t fit the bill?

It should be an integer large enough to be used as size/index of any allocated array in memory (both for 32 and 64 systems).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in CoinUtils/src/CoinHelperFunctions.hpp at the CoinMemcpyN implementation around lines 331 and 341, then inspect the declaration and call sites of CoinByteArray. Verify the intended integer type for the size parameter and compile the affected CoinUtils sources with clang 10. Done means the reported invalid shift and modulo operands no longer occur.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.