dogecoin / dogecoin

very currency
MIT License
14.4k stars 2.8k forks source link

Missing include for std::set in sync.cpp #3516

Open patricklodder opened 1 month ago

patricklodder commented 1 month ago

Originally posted by @victorsk2019 in https://github.com/dogecoin/dogecoin/issues/3512#issuecomment-2050228101

Just a quick note that I also ran test on another Linux installation in VirtualBox and got following compilation error:

sync.cpp:60:14: error: ‘set’ in namespace ‘std’ does not name a template type
   60 | typedef std::set<std::pair<void*, void*> > InvLockOrders;
      |              ^~~
sync.cpp:14:1: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’?
   13 | #include <boost/thread.hpp>
  +++ |+#include <set>
   14 | 
sync.cpp:72:5: error: ‘InvLockOrders’ does not name a type; did you mean ‘LockOrders’?
   72 |     InvLockOrders invlockorders;
      |     ^~~~~~~~~~~~~
      |     LockOrders
sync.cpp: In function ‘void push_lock(void*, const CLockLocation&, bool)’:
sync.cpp:123:18: error: ‘struct LockData’ has no member named ‘invlockorders’; did you mean ‘lockorders’?
  123 |         lockdata.invlockorders.insert(p2);
      |                  ^~~~~~~~~~~~~
      |                  lockorders
sync.cpp: In function ‘void DeleteLock(void*)’:
sync.cpp:172:18: error: ‘struct LockData’ has no member named ‘invlockorders’; did you mean ‘lockorders’?
  172 |         lockdata.invlockorders.erase(invitem);
      |                  ^~~~~~~~~~~~~
      |                  lockorders
sync.cpp:175:5: error: ‘InvLockOrders’ has not been declared
  175 |     InvLockOrders::iterator invit = lockdata.invlockorders.lower_bound(item);
      |     ^~~~~~~~~~~~~
sync.cpp:176:12: error: ‘invit’ was not declared in this scope; did you mean ‘int’?
  176 |     while (invit != lockdata.invlockorders.end() && invit->first == cs) {
      |            ^~~~~
      |            int
sync.cpp:176:30: error: ‘struct LockData’ has no member named ‘invlockorders’; did you mean ‘lockorders’?
  176 |     while (invit != lockdata.invlockorders.end() && invit->first == cs) {
      |                              ^~~~~~~~~~~~~
      |                              lockorders
sync.cpp:179:18: error: ‘struct LockData’ has no member named ‘invlockorders’; did you mean ‘lockorders’?
  179 |         lockdata.invlockorders.erase(invit++);
      |                  ^~~~~~~~~~~~~
      |                  lockorders
make[2]: *** [Makefile:6600: libdogecoin_util_a-sync.o] Error 1
make[2]: Leaving directory '/home/me/projects/fromgit/dogecoin/PR-3512/dogecoin/src'
make[1]: *** [Makefile:9882: all-recursive] Error 1
make[1]: Leaving directory '/home/me/projects/fromgit/dogecoin/PR-3512/dogecoin/src'
make: *** [Makefile:695: all-recursive] Error 1

This error was fixed by adding #include <set> in sync.cpp (as message advises).

config_vbox.log


Additional variable for reproduction: must be configured with --enable-debug for this to occur on boost > 1.78

patricklodder commented 1 month ago

@victorsk2019

I see in your config.log that this is gcc 13.2, but I cannot find your boost version in there. Which version of boost are you using? You can find this with:

$ grep "define BOOST_VERSION " /path/to/include/boost/version.hpp
#define BOOST_VERSION 108200
victorsk2019 commented 1 month ago

$ grep "define BOOST_VERSION " /path/to/include/boost/version.hpp

define BOOST_VERSION 108200

I get #define BOOST_VERSION 108400

patricklodder commented 1 month ago

Conditions for this to occur:

I have reproduced this on gentoo x86_64 with boost 1.84 and macOS arm64 with boost 1.82.

The cleanest fix would be to write unit tests for #3313 and use that, as that fully takes care of this issue.