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

Fix clang compilation when T is constructible from other types #64

Merged
merged 2 commits into from
Nov 5, 2018

Conversation

Lastique
Copy link
Member

@Lastique Lastique commented Nov 4, 2018

The problem was with copy/move constructors of boost::optional<T>, which invoked optional_base<T> constructors with a single argument. Since optional_base has copy/move constructors along with initializing constructors taking a single argument, the latter may be considered by the compiler for viability. While doing so, the compiler may instantiate the template constructor of T with an argument of optional_base<T>, which in turn may fail if the constructor attempts to inspect the type of its argument (e.g. to constrain the set of acceptable types). Specifically, this happens with clang in C++03 mode, when boost::multiprecision::number is wrapped in boost::optional and a copy constructor of boost::optional is invoked.

This PR fixes the problem by destinguishing copy/move constructors of optional_base from initializing constructors with an additional tag argument. The PR also adds a test.

The problem was with copy/move constructors of boost::optional<T>, which invoked
optional_base<T> constructors with a single argument. Since optional_base has
copy/move constructors along with initializing constructors taking a single
argument, the latter may be considered by the compiler for viability. While
doing so, the compiler may instantiate the template constructor of T with
an argument of optional_base<T>, which in turn may fail if the constructor
attempts to inspect the type of its argument (e.g. to constrain the set of
acceptable types). Specifically, this happens with clang in C++03 mode,
when boost::multiprecision::number is wrapped in boost::optional and
a copy constructor of boost::optional is invoked.

This commit fixes the problem by destinguishing copy/move constructors of
optional_base from initializing constructors with an additional tag argument.
@Lastique
Copy link
Member Author

Lastique commented Nov 4, 2018

Reference to the problem with Boost.Multiprecision: boostorg/integer#11 (comment).

@akrzemi1 akrzemi1 merged commit 2f3cf1c into boostorg:develop Nov 5, 2018
@Lastique Lastique deleted the fix_constructible_from_any branch November 5, 2018 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants