Skip to content

__attribute__((enable_if(...))) checked before constraints #115230

@pkasting

Description

@pkasting

When using __attribute__((enable_if(...))) with a condition that may be ill-formed, you cannot use a requires clause to constrain the function to only be considered in the well-formed cases, because apparently the enable_if condition is considered first.

The workaround is to use SFINAE instead, which is ugly.

Sample code: https://godbolt.org/z/x3MjWv1ET

IMO, enable_if should be considered after constraint satisfaction (like with SFINAE), not before. Optionally, if the condition for enable_if is ill-formed the overload could just be considered to be not enabled, but that might be a bridge too far.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions