Skip to content

[concepts] [ice] substitution into constraint expression resulted in a non-constant expression #50845

@marehr

Description

@marehr
Bugzilla Link 51503
Version trunk
OS Linux
CC @AaronBallman,@JohelEGP,@zygoloid

Extended Description

Hi clang-team,

the following code does not compile with clang trunk:

template <typename urng_t>
struct contiguous_range
{
    template <bool const_range>
        requires (const_range == false)
    using basic_iterator = int;

    auto begin()
    {
        return basic_iterator<false>{};
    }
};

https://godbolt.org/z/jobYveoe3

with the error

<source>:5:19: error: substitution into constraint expression resulted in a non-constant expression
        requires (const_range == false)
                  ^~~~~~~~~~~~~~~~~~~~
<source>:10:16: note: while checking constraint satisfaction for template 'basic_iterator<false>' required here
        return basic_iterator<false>{};
               ^~~~~~~~~~~~~~~~~~~~~
<source>:5:19: note: subexpression not valid in a constant expression
        requires (const_range == false)
                  ^

MSVC 16.11, and gcc 11.2 are able to compile this code. A curious side note: If you remove template <typename urng_t> clang does compile this code snippet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsconfirmedVerified by a second party

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions