Skip to content

Only first destructor is considered when constraints are used #45614

@qookei

Description

@qookei
Bugzilla Link 46269
Version trunk
OS Linux
CC @efriedma-quic,@qookei,@zygoloid,@saarraz

Extended Description

When there are multiple destructors constrained with a requires clause, only the first one is considered, like in the following code:

template <bool B>
struct A {
    ~A() requires (B) { }
    ~A() requires (!B) { }
};

A<false> x;

The compiler reports the following error:

<source>:7:10: error: invalid reference to function '~A': constraints not satisfied
A<false> x;
         ^
<source>:3:20: note: because 'false' evaluated to false
    ~A() requires (B) { }
                   ^

The compiler prematurely reports an error about an invalid reference to the destructor because the constraint on the first variant was not satisfied, without checking the second variant.

The same code compiles with GCC without any problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 concepts

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions