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

gcc 9.3 claims operator++ is ambiguous #61

Open
usefulcat opened this issue Feb 19, 2021 · 1 comment
Open

gcc 9.3 claims operator++ is ambiguous #61

usefulcat opened this issue Feb 19, 2021 · 1 comment

Comments

@usefulcat
Copy link

I added the following test case to tests.cpp, which is just a trivial combination of the contents of the PreIncrementable and PostIncrementable tests:

TEST_CASE("PreAndPostIncrementable")
{
    using StrongInt = fluent::NamedType<int, struct StrongIntTag, fluent::PreIncrementable, fluent::PostIncrementable>;
    {
        StrongInt a{1};
        StrongInt b = ++a;
        CHECK( a.get() == 2 );
        CHECK( b.get() == 2 );
    }
    {
        StrongInt a{1};
        StrongInt b = a++;
        CHECK( a.get() == 2 );
        CHECK( b.get() == 1 );
    }
}

gcc 9.3 fails to compile it, saying "error: request for member ‘operator++’ is ambiguous".

I thought I would try fixing it myself but so far I haven't been able to figure out why it doesn't work, let alone how to fix it. This problem also affects any type that uses Arithmetic, which is how I originally discovered it.

@Nicholas42
Copy link

Ran into the same problem. I think this is a bug in gcc. I just opened a question stackoverflow regarding this: https://stackoverflow.com/questions/69540048/gcc-ambiguous-inherited-increment

I don't think that the hot-fix (using the operators) will work in general for NamedType, since it would have to know if it is pre- and postincrementable. But adding the following lines to struct Arithmetic fixes it for arithmetic types at least:

    using PostIncrementable<T>::operator++;
    using PreIncrementable<T>::operator++;
    using PostDecrementable<T>::operator--;
    using PreDecrementable<T>::operator--;

I will add a pull request for this.

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