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

Inheriting constructors of isl::optional<T> results in a compilation error on gcc 6.4 and lower #55

Closed
improbablejan opened this issue Feb 26, 2020 · 3 comments
Assignees

Comments

@improbablejan
Copy link

The following code fails to compile on gcc versions 6.4 and lower:

struct foo : nonstd::optional<int> {
    using nonstd::optional<int>::optional;
};

while it appears to work with gcc version 7.1 and above. The compilation error produced (with --std=c++14 GCC 6.4 on godbolt.org):

<source>:1704:34: error: 'template<class U> constexpr foo::foo(U&&)' inherited from 'nonstd::optional_lite::optional<int>'

     using nonstd::optional<int>::optional;

                                  ^~~~~~~~

<source>:1704:34: error: conflicts with version inherited from 'nonstd::optional_lite::optional<int>'

<source>:1704:34: error: 'template<class U> foo::foo(nonstd::optional_lite::optional<T>&&)' inherited from 'nonstd::optional_lite::optional<int>'

<source>:1704:34: error: conflicts with version inherited from 'nonstd::optional_lite::optional<int>'

<source>:1704:34: error: 'template<class U> foo::foo(const nonstd::optional_lite::optional<T>&)' inherited from 'nonstd::optional_lite::optional<int>'

<source>:1704:34: error: conflicts with version inherited from 'nonstd::optional_lite::optional<int>'

Compiler returned: 1

@improbable-nickkrempel believes it could be due to the change in inheriting constructor semantics
which resolves issue 1941. Switching the SFINAE method used from a default argument to a default template type does seem to resolve the issue. Is there any reason why optional_REQUIRES_A is used when using SFINAE with constructors instead of optional_REQUIRES_T, or could the method be switched in order to better support older GCC versions?

@martinmoene martinmoene self-assigned this Feb 26, 2020
@martinmoene
Copy link
Owner

@improbablejan, started working on it...

martinmoene added a commit that referenced this issue Mar 5, 2020
martinmoene added a commit that referenced this issue Mar 5, 2020
martinmoene added a commit that referenced this issue Mar 5, 2020
martinmoene added a commit that referenced this issue Mar 5, 2020
martinmoene added a commit that referenced this issue Mar 5, 2020
martinmoene added a commit that referenced this issue Mar 5, 2020
@martinmoene
Copy link
Owner

@improbablejan, it looks like nonstd::optional<> can now be inherited from.
Thanks for your helpful suggestion.

@improbablejan
Copy link
Author

Thanks for the quick turnaround!

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

No branches or pull requests

2 participants