Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS <= 10.9: error: chosen constructor is explicit in copy-initialization #339

Closed
ilovezfs opened this issue Sep 3, 2016 · 6 comments
Closed

Comments

@ilovezfs
Copy link

ilovezfs commented Sep 3, 2016

The following is a regression from cereal 1.1.2, which does not have this problem.

Full build log: https://gist.github.com/ilovezfs/43068bcbd2aaf678017fbf88f7f62d5c

When trying to build cereal 1.2.1 or the develop branch @ 1e5e648 on macOS <= 10.9 the build fails with

/tmp/cereal-20160903-81215-l0wzgn/./include/cereal/details/polymorphic_impl.hpp:227:61: error: chosen constructor is explicit in copy-initialization
          auto & derivedMap = baseMap.insert( lb, {baseKey, {}} )->second;
                                                            ^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/map:838:14: note: constructor declared here
    explicit map(const key_compare& __comp = key_compare())
             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/utility:262:37: note: passing argument to parameter '__y' here
    pair(const _T1& __x, const _T2& __y)

This does not affect macOS 10.10 or 10.11.

@AzothAmmo
Copy link
Contributor

Sounds like whatever version of clang Apple is using there has an explicit default constructor for map. Try this and see if it fixes the problem:

Replace line 227 with:

auto & derivedMap = baseMap.insert( lb, {baseKey, std::map<std::type_index, std::vector<PolymorphicCaster const*>>{}} )->second;

I don't have any way of easily testing this myself so if you have to play around to get this to work let me know what had to change.

@jasperges
Copy link

Today I also encountered this issue and after replacing the line like you suggested it worked fine. Thanks.

@headupinclouds
Copy link
Contributor

I encountered the same issue with with a clang-3.8 + libc++ build on an Ubuntu Trusty machine. Are there any objections to a PR with the above fix #339 (comment)

auto & derivedMap = baseMap.insert( lb, {baseKey, std::map<std::type_index, std::vector<PolymorphicCaster const*>>{}} )->second;

@headupinclouds
Copy link
Contributor

I believe this was addressed here: fcef0da#commitcomment-23652411

@headupinclouds
Copy link
Contributor

I've tested the fix from develop and it works fine. I believe this issue can be closed.

headupinclouds added a commit to headupinclouds/hunter that referenced this issue Aug 15, 2017
General update to 1.2.2 from HEAD to include fix for libcxx toolchain on some platforms.

See: USCiLab/cereal#339 (comment)
@ilovezfs
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants