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

C++ parser: incorrectly selecting partial specialisation without regard for SFINAE in constructor call #455

Open
davmac314 opened this issue Jul 11, 2023 · 0 comments

Comments

@davmac314
Copy link
Contributor

Describe the bug
There is a case not properly handled for SFINAE in the parser / semantic analysis. When a specialisation uses expressions involving constructors, at least of basic types (including void), SFINAE errors are not propagated and do not prevent selection of the specialisation when they should.

To Reproduce

The followig code exhibits the issue, see declaration of B b1 { ip };. This is marked as an error because the partial specialisation is selected when it should be rejected.

template <class, typename = void>
struct A
{
    using type = int *;
};

template <class T>
struct A<T, decltype(void(typename T::p()))>
{
    using type = typename T::p;
};

class d { };

class B {
public:
    using p = typename A<d>::type;

public:
    explicit B(p) {}
};

int *ip = nullptr;
B b1 { ip };
B::p jp = nullptr;

I have a fix which I will post shortly.

davmac314 added a commit to davmac314/cdt that referenced this issue Jul 12, 2023
… failure

This change prevents invalid partial specialisations from being chosen
when
instantiating a template in cases where the expression for the
type/value of a template parameter involves a constructor call.
davmac314 added a commit to davmac314/cdt that referenced this issue Sep 24, 2023
… failure

This change prevents invalid partial specialisations from being chosen
when
instantiating a template in cases where the expression for the
type/value of a template parameter involves a constructor call.
davmac314 added a commit to davmac314/cdt that referenced this issue Sep 24, 2023
… failure

This change prevents invalid partial specialisations from being chosen
when
instantiating a template in cases where the expression for the
type/value of a template parameter involves a constructor call.
jonahgraham pushed a commit that referenced this issue Dec 28, 2023
)

This change prevents invalid partial specialisations from being chosen
when
instantiating a template in cases where the expression for the
type/value of a template parameter involves a constructor call.
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

1 participant