https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125459

            Bug ID: 125459
           Summary: [contracts] "contract condition is not constant" in
                    constexpr function
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chzn at mail dot ustc.edu.cn
  Target Milestone: ---

https://godbolt.org/z/7KEeYnc8G

the following code:

```
#include <vector>
constexpr auto f(std::vector<int> a) {
    contract_assert(a.size()==1);
    return a[0];
}
constexpr auto a=f({1});        // OK
constexpr auto b=f({ f({1}) }); // error: contract condition is not constant
```

result in:

```
<source>:3:5: error: contract condition is not constant
    3 |     contract_assert(a.size()==1);
      |     ^~~~~~~~~~~~~~~
```

Reply via email to