On Sun 08 Oct 2017 at 00:30:53 +0200, Rhialto wrote: > I'll have to look later at this. constants::request_list_constants::bucket_count is meant to be a compile-time constant which is presubably inlined everywhere. It is used as array sizes and template argument. Why g++ still generates a reference to it, I don't know. I tried to hack around it by replacing all uses of it by a constant, but then I discovered it is also used indirectly via a template argument which gives the namespace... Explicitly instantiating the bucket_count causes g++ to complain request_list.cc:54:37: error: duplicate initialization of 'torrent::request_list_constants::bucket_count' const int request_list_constants::bucket_count = REQUEST_LIST_CONSTANTS__BUCKET_COUNT; as with the patches below, which are in the state that I tried last. Leaving out the instantiating still leaves me with the original link error about the same thing being undefined. Adding GCC_REQD+=4.9 does not help, nor USE_LANGUAGES+=c++14. I'm unsure how to continue working around what clearly seems a g++ bug. $NetBSD$ --- src/protocol/request_list.h.orig 2015-08-08 15:01:49.000000000 +0000 +++ src/protocol/request_list.h @@ -50,13 +50,14 @@ namespace torrent { class PeerChunks; class Delegator; +#define REQUEST_LIST_CONSTANTS__BUCKET_COUNT 4 struct request_list_constants { - static const int bucket_count = 4; + static const int bucket_count = REQUEST_LIST_CONSTANTS__BUCKET_COUNT; - static const torrent::instrumentation_enum instrumentation_added[bucket_count]; - static const torrent::instrumentation_enum instrumentation_moved[bucket_count]; - static const torrent::instrumentation_enum instrumentation_removed[bucket_count]; - static const torrent::instrumentation_enum instrumentation_total[bucket_count]; + static const torrent::instrumentation_enum instrumentation_added[REQUEST_LIST_CONSTANTS__BUCKET_COUNT]; + static const torrent::instrumentation_enum instrumentation_moved[REQUEST_LIST_CONSTANTS__BUCKET_COUNT]; + static const torrent::instrumentation_enum instrumentation_removed[REQUEST_LIST_CONSTANTS__BUCKET_COUNT]; + static const torrent::instrumentation_enum instrumentation_total[REQUEST_LIST_CONSTANTS__BUCKET_COUNT]; template <typename Type> static void destroy(Type& obj); $NetBSD$ --- src/protocol/request_list.cc.orig 2015-08-08 15:01:49.000000000 +0000 +++ src/protocol/request_list.cc @@ -51,26 +51,27 @@ #include "request_list.h" namespace torrent { + const int request_list_constants::bucket_count = REQUEST_LIST_CONSTANTS__BUCKET_COUNT; -const instrumentation_enum request_list_constants::instrumentation_added[bucket_count] = { +const instrumentation_enum request_list_constants::instrumentation_added[REQUEST_LIST_CONSTANTS__BUCKET_COUNT] = { INSTRUMENTATION_TRANSFER_REQUESTS_QUEUED_ADDED, INSTRUMENTATION_TRANSFER_REQUESTS_UNORDERED_ADDED, INSTRUMENTATION_TRANSFER_REQUESTS_STALLED_ADDED, INSTRUMENTATION_TRANSFER_REQUESTS_CHOKED_ADDED }; -const instrumentation_enum request_list_constants::instrumentation_moved[bucket_count] = { +const instrumentation_enum request_list_constants::instrumentation_moved[REQUEST_LIST_CONSTANTS__BUCKET_COUNT] = { INSTRUMENTATION_TRANSFER_REQUESTS_QUEUED_MOVED, INSTRUMENTATION_TRANSFER_REQUESTS_UNORDERED_MOVED, INSTRUMENTATION_TRANSFER_REQUESTS_STALLED_MOVED, INSTRUMENTATION_TRANSFER_REQUESTS_CHOKED_MOVED }; -const instrumentation_enum request_list_constants::instrumentation_removed[bucket_count] = { +const instrumentation_enum request_list_constants::instrumentation_removed[REQUEST_LIST_CONSTANTS__BUCKET_COUNT] = { INSTRUMENTATION_TRANSFER_REQUESTS_QUEUED_REMOVED, INSTRUMENTATION_TRANSFER_REQUESTS_UNORDERED_REMOVED, INSTRUMENTATION_TRANSFER_REQUESTS_STALLED_REMOVED, INSTRUMENTATION_TRANSFER_REQUESTS_CHOKED_REMOVED }; -const instrumentation_enum request_list_constants::instrumentation_total[bucket_count] = { +const instrumentation_enum request_list_constants::instrumentation_total[REQUEST_LIST_CONSTANTS__BUCKET_COUNT] = { INSTRUMENTATION_TRANSFER_REQUESTS_QUEUED_TOTAL, INSTRUMENTATION_TRANSFER_REQUESTS_UNORDERED_TOTAL, INSTRUMENTATION_TRANSFER_REQUESTS_STALLED_TOTAL, -Olaf. -- ___ Olaf 'Rhialto' Seibert -- Wayland: Those who don't understand X \X/ rhialto/at/falu.nl -- are condemned to reinvent it. Poorly.
Attachment:
signature.asc
Description: PGP signature