[llvm-bugs] [Bug 51503] New: [concepts] substitution into constraint expression resulted in a non-constant expression

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 17 04:38:16 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51503

            Bug ID: 51503
           Summary: [concepts] substitution into constraint expression
                    resulted in a non-constant expression
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: llvm at marehr.dialup.fu-berlin.de
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Hi clang-team,

the following code does not compile with clang trunk:

```c++
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210817/9806b048/attachment.html>


More information about the llvm-bugs mailing list