Project

General

Profile

tickets #115877

google-or-tools: fix "looses precision" error

Added by cboltz 5 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Good First Issues
Target version:
-
Start date:
2022-08-28
Due date:
% Done:

0%

Estimated time:

Description

google-or-tools fails with

[  845s] /home/abuild/rpmbuild/BUILD/or-tools-9.3/ortools/constraint_solver/constraint_solveri.h: In function 'uint64_t operations_research::Hash1(void*)':
[  845s] /home/abuild/rpmbuild/BUILD/or-tools-9.3/ortools/constraint_solver/constraint_solveri.h:247:16: error: cast from 'void*' to 'uint32_t' {aka 'unsigned int'} loses precision [-fpermissive]
[  845s]   247 |   return Hash1(reinterpret_cast<uint32_t>(ptr));
[  845s]       |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The relevant code is

inline uint64_t Hash1(void* const ptr) {
#if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || \
    defined(__aarch64__)
  return Hash1(reinterpret_cast<uint64_t>(ptr));
#else
  return Hash1(reinterpret_cast<uint32_t>(ptr));
#endif
}

Hint: s390x is a 64 bit architecture.

Also available in: Atom PDF