[CXX-1688] MongoDB CXX driver does not compile with standard polyfill. Created: 06/Nov/18 Updated: 28/Oct/23 Resolved: 15/Nov/18 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | Build |
| Affects Version/s: | 3.4.0 |
| Fix Version/s: | 3.5.0, 3.4.1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Piotr Szczepanski | Assignee: | Kevin Albertson |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Ubuntu 18.04/Arch, GCC 8.2.0 |
||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
When trying to build MongoCXX driver with standard polyfill, the build fails. Steps to reproduce:
CMake does state that it will be using C++17 std library polyfills:
When using MNMLSTC, everything is working fine. |
| Comments |
| Comment by Githook User [ 15/Nov/18 ] | ||
|
Author: {'name': 'Piotr Szczepanski', 'email': 'piotr.szczepanski@avast.com', 'username': 'tamaroth'}Message: | ||
| Comment by Kevin Albertson [ 08/Nov/18 ] | ||
|
I checked with gcc 8.2 and agree with your analysis. I confirmed that your patch fixes this on my end. I commented in the pull request requesting a small change. Thank you for the great work! | ||
| Comment by Piotr Szczepanski [ 08/Nov/18 ] | ||
|
I have found a reason for the failure. When constructing std::optional, the underlying object (read_concern, write_concern, and read_preference) is created inside std::optional as the object is not created in-place and as a result it does not have access to the private constructor of that class. To circumvent this, we have to create the object explicitly in the transaction::impl method and then create an stdx::optional<> from already existing object (using constructor #8 of optional). My pull request now reflects this fact. Please confirm on your end and let me know if you came to the same conclusions. Thanks for your time! | ||
| Comment by Kevin Albertson [ 07/Nov/18 ] | ||
|
Thank you for your the bug report and contribution! It isn't clear to me why this is necessary. Since options::transaction is declared as a friend of read_concern and read_preference I'd think that options::transactions::impl would have access to the private constructors of read_concern and read_preference. I'll reproduce on GCC 8.x and investigate. | ||
| Comment by Piotr Szczepanski [ 07/Nov/18 ] | ||
|
I have created a ticket for the string conversion: For the current ticket, I have created a pull request that solves the issue: | ||
| Comment by Piotr Szczepanski [ 07/Nov/18 ] | ||
|
Additionally, when the abovementioned classes are fixed, there is another error:
Which can be fixed (for all polyfill variants) by replacing name.to_string().c_str() with name.data(). | ||
| Comment by Piotr Szczepanski [ 07/Nov/18 ] | ||
|
It seems the culprit is the private constructor of the read_concern, write_concern, and read_preference classes that take a unique ptr to their implementation. If you make that constructor public, everything is compiling without a problem. |