Skip to content

requires{ member_fn; } within a member function is true, despite member_fn; being an error #51246

@nyanpasu64

Description

@nyanpasu64
Bugzilla Link 51904
Version trunk
OS Linux
Attachments Test case for requires{} expressions
CC @zygoloid

Extended Description

If I define a class with a void member_fn() which contains requires{ member_fn; }, it evaluates to true on Clang but is an error on GCC, despite member_fn; being an error on both compilers.

If I define a template<typename T> Class : T instantiated with a T containing base_fn(), and Class contains a member function with requires{ T::base_fn; }, it evaluates to true on Clang but false on GCC, despite base_fn; being an error on both compilers.

Is this a Clang bug, or is my code ill-formed? I was using the value of requires{} as an input to if constexpr or static_assert, rather than as a concept or template bound; is this allowed?

I've attached a file testing whether requires{} in various positions is true, false, or an error to evaluate.

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

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions