Page MenuHomePhabricator

depends: Fix compile error for Qt when using newer GCC 11+
ClosedPublic

Authored by PiRK on Apr 14 2023, 16:32.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC8e33573475d7: depends: Fix compile error for Qt when using newer GCC 11+
Summary

This patch fixes a compile error encountered on newer Ubuntu when building Qt 5.9.7. The issue was observed on Ubuntu 21.10 and 22.04, where a missing include caused compile errors.

This patch just fixes the error by including <limits>.

See BCHN issue #417

This is a backport of https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/merge_requests/1530

Note: the error fixed by this is also seen when compiling Qt 5.12.10 and Qt 5.12.11
It can be dropped with Qt 5.15.x

Test Plan

On Ubuntu 22.04, run

cd depends
HOST=x86_64-linux-gnu make qt

Before this patch, it errors with this log:

In file included from /home/pierre/dev/bitcoin-abc/depends/work/build/x86_64-linux-gnu/qt/5.9.8-23c80104b59/qtbase/src/corelib/tools/qbytearray.cpp:42:
/home/pierre/dev/bitcoin-abc/depends/work/build/x86_64-linux-gnu/qt/5.9.8-23c80104b59/qtbase/src/corelib/tools/qbytearraymatcher.h: In static member function ‘static QStaticByteArrayMatcherBase::Skiptable QStaticByteArrayMatcherBase::generate(const char*, uint)’:
/home/pierre/dev/bitcoin-abc/depends/work/build/x86_64-linux-gnu/qt/5.9.8-23c80104b59/qtbase/src/corelib/tools/qbytearraymatcher.h:103:38: error: ‘numeric_limits’ is not a member of ‘std’
  103 |         const auto uchar_max = (std::numeric_limits<uchar>::max)();
      |                                      ^~~~~~~~~~~~~~
/home/pierre/dev/bitcoin-abc/depends/work/build/x86_64-linux-gnu/qt/5.9.8-23c80104b59/qtbase/src/corelib/tools/qbytearraymatcher.h:103:58: error: expected primary-expression before ‘>’ token
  103 |         const auto uchar_max = (std::numeric_limits<uchar>::max)();
      |                                                          ^
/home/pierre/dev/bitcoin-abc/depends/work/build/x86_64-linux-gnu/qt/5.9.8-23c80104b59/qtbase/src/corelib/tools/qbytearraymatcher.h:103:61: error: ‘::max’ has not been declared; did you mean ‘std::max’?
  103 |         const auto uchar_max = (std::numeric_limits<uchar>::max)();
      |                                                             ^~~
      |                                                             std::max
In file included from /usr/include/c++/11/algorithm:62,
...

After the patch, no error.

Run also gitian builds on CI

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Apr 14 2023, 16:32

@bot gitian-win gitian-osx gitian-linux

PiRK retitled this revision from depends: Fix compile error for Qt 5.9.7 when using newer GCC 11+ to depends: Fix compile error for Qt when using newer GCC 11+.Apr 14 2023, 16:33
PiRK edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Apr 14 2023, 21:35