[SERVER-32516] Fails to compile with Boost 1.66 Created: 02/Jan/18  Updated: 30/Oct/23  Resolved: 31/Jan/18

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: 3.6.1
Fix Version/s: 3.6.3, 3.7.2

Type: Bug Priority: Major - P3
Reporter: Jelle van der Waa Assignee: Judah Schvimer
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
related to SERVER-27881 Upgrade to boost >= 1.63 Closed
is related to SERVER-33508 Fails to compile with Boost 1.66 Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.6
Steps To Reproduce:

Compile with: scons core tools --use-system-pcre --use-system-snappy --use-system-yaml --use-system-zlib --use-system-wiredtiger --use-sasl-client --ssl --disable-warnings-as-errors --use-system-boost
With Boost 1.66 installed.

Sprint: Repl 2018-02-12
Participants:

 Description   

Mongo fails to compile with Boost 1.66:

src/mongo/db/repl/oplog_fetcher.cpp: In function 'mongo::StatusWith<boost::optional<mongo::rpc::OplogQueryMetadata> > mongo::repl::{anonymous}::parseOplogQueryMetadata(mongo::Fetcher::QueryResponse)':
src/mongo/db/repl/oplog_fetcher.cpp:248:93: error: no matching function for call to 'make_optional<mongo::rpc::OplogQueryMetadata>(mongo::rpc::OplogQueryMetadata&)'
         oqMetadata = boost::make_optional<rpc::OplogQueryMetadata>(metadataResult.getValue());
                                                                                             ^
In file included from /usr/include/boost/optional.hpp:15:0,
                 from src/mongo/base/status_with.h:30,
                 from src/mongo/db/repl/oplog_fetcher.h:34,
                 from src/mongo/db/repl/oplog_fetcher.cpp:33:
/usr/include/boost/optional/optional.hpp:1367:56: note: candidate: template<class T> boost::optional<typename boost::decay<T>::type> boost::make_optional(T&&)
 optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type> make_optional ( T && v  )
                                                        ^~~~~~~~~~~~~
/usr/include/boost/optional/optional.hpp:1367:56: note:   template argument deduction/substitution failed:
src/mongo/db/repl/oplog_fetcher.cpp:248:91: note:   cannot convert 'metadataResult.mongo::StatusWith<mongo::rpc::OplogQueryMetadata>::getValue()' (type 'mongo::rpc::OplogQueryMetadata') to type 'mongo::rpc::OplogQueryMetadata&&'
         oqMetadata = boost::make_optional<rpc::OplogQueryMetadata>(metadataResult.getValue());
                                                                    ~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from /usr/include/boost/optional.hpp:15:0,
                 from src/mongo/base/status_with.h:30,
                 from src/mongo/db/repl/oplog_fetcher.h:34,
                 from src/mongo/db/repl/oplog_fetcher.cpp:33:
/usr/include/boost/optional/optional.hpp:1375:56: note: candidate: template<class T> boost::optional<typename boost::decay<T>::type> boost::make_optional(bool, T&&)
 optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type> make_optional ( bool cond, T && v )
                                                        ^~~~~~~~~~~~~
/usr/include/boost/optional/optional.hpp:1375:56: note:   template argument deduction/substitution failed:
src/mongo/db/repl/oplog_fetcher.cpp:248:93: note:   candidate expects 2 arguments, 1 provided
         oqMetadata = boost::make_optional<rpc::OplogQueryMetadata>(metadataResult.getValue());
                                                                                             ^
scons: *** [build/opt/mongo/db/repl/oplog_fetcher.o] Error 1
scons: building terminated because of errors.
build/opt/mongo/db/repl/oplog_fetcher.o failed: Error 1



 Comments   
Comment by Marek Skalický [ 27/Feb/18 ]

https://jira.mongodb.org/browse/SERVER-33508

Comment by Andrew Morrow (Inactive) [ 26/Feb/18 ]

mskalick - Would you mind opening a new ticket for the problem with the test? We don't generally commit to tickets that are already closed with fixVersions, as it gets confusing.

Comment by Githook User [ 12/Feb/18 ]

Author:

{'email': 'judah@mongodb.com', 'name': 'Judah Schvimer', 'username': 'judahschvimer'}

Message: SERVER-32516 remove make_optional type

(cherry picked from commit 3c34eda8d8a38b982a1659b919e9f4b5971ba512)
Branch: v3.6
https://github.com/mongodb/mongo/commit/5e7b0f5f38a4103dae22e95adf227a53d5c83545

Comment by Marek Skalický [ 12/Feb/18 ]

diff --git a/src/mongo/executor/network_interface_mock_test.cpp b/src/mongo/executor/network_interface_mock_test.cpp
index b1a2e4edff..c41aad1f8c 100644
--- a/src/mongo/executor/network_interface_mock_test.cpp
+++ b/src/mongo/executor/network_interface_mock_test.cpp
@@ -143,7 +143,7 @@ TEST_F(NetworkInterfaceMockTest, ConnectionHook) {
         [&](const HostAndPort& remoteHost) {
             makeRequestCalled = true;
             hostCorrectForRequest = (remoteHost == testHost());
-            return boost::make_optional<RemoteCommandRequest>(expectedRequest);
+            return boost::make_optional(expectedRequest);
         },
         [&](const HostAndPort& remoteHost, RemoteCommandResponse&& response) {
             handleReplyCalled = true;

Needs to be changed too.

Comment by Andrew Morrow (Inactive) [ 31/Jan/18 ]

jwakely - We have committed the obvious fix on master, and I've requested that it get backported to 3.6.

Comment by Githook User [ 31/Jan/18 ]

Author:

{'email': 'judah@mongodb.com', 'name': 'Judah Schvimer', 'username': 'judahschvimer'}

Message: SERVER-32516 remove make_optional type
Branch: master
https://github.com/mongodb/mongo/commit/3c34eda8d8a38b982a1659b919e9f4b5971ba512

Comment by Jonathan Wakely [ 30/Jan/18 ]

OK, thanks for the reply. For the Fedora package of mongodb we un-bundle the Boost lib (as is Fedora policy) and so need to be able to build against the default version of Boost in Fedora. I've just updated the version of Boost in Fedora rawhide to 1.66.0 and so I'm following another Fedora policy of trying to get bugs fixed upstream first. The maintainer of the Fedora package can just patch it locally until there is an upstream fix.

Comment by Andrew Morrow (Inactive) [ 30/Jan/18 ]

jwakely - I agree that the code is easily fixed. We haven't made a priority of fixing it since we build against a fixed copy of boost. We weren't planning to do anything about it until we upgraded that copy in SERVER-27881, which would force us to. However, since the fix is trivial, I'll see if we can get it resolved sooner.

Comment by Jonathan Wakely [ 30/Jan/18 ]

This code is just silly, there's no point using make_optional if you defeat argument deduction, since the whole point of it is to deduce the type.

--- mongo-r3.6.2/src/mongo/db/repl/oplog_fetcher.cpp~   2018-01-30 18:19:15.398613407 +0000
+++ mongo-r3.6.2/src/mongo/db/repl/oplog_fetcher.cpp    2018-01-30 18:19:43.245561408 +0000
@@ -245,7 +245,7 @@
         if (!metadataResult.isOK()) {
             return metadataResult.getStatus();
         }
-        oqMetadata = boost::make_optional<rpc::OplogQueryMetadata>(metadataResult.getValue());
+        oqMetadata = boost::make_optional(metadataResult.getValue());
     }
     return oqMetadata;
 }

Or if you need to be explicit about the type, just construct an rvalue, don't use make_optional:

--- mongo-r3.6.2/src/mongo/db/repl/oplog_fetcher.cpp~   2018-01-30 18:19:15.398613407 +0000
+++ mongo-r3.6.2/src/mongo/db/repl/oplog_fetcher.cpp    2018-01-30 18:24:48.927990608 +0000
@@ -245,7 +245,7 @@
         if (!metadataResult.isOK()) {
             return metadataResult.getStatus();
         }
-        oqMetadata = boost::make_optional<rpc::OplogQueryMetadata>(metadataResult.getValue());
+        oqMetadata = boost::optional<rpc::OplogQueryMetadata>(metadataResult.getValue());
     }
     return oqMetadata;
 }

Generated at Thu Feb 08 04:30:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.