| Issue |
184985
|
| Summary |
[Clang] `if consteval {}` causes more constant evaluation steps than an empty statement
|
| Labels |
clang:frontend,
constexpr
|
| Assignees |
|
| Reporter |
frederick-vs-ja
|
This example shows that Clang currently considers `if consteval {}` causes more constant evaluation steps than `;`. [Godbolt link](https://godbolt.org/z/acGs7KsEY).
```C++
constexpr bool test_empty_if_consteval(int n) {
for (int i = 0; i < n; ++i)
if consteval {}
return true;
}
constexpr bool test_empty(int n) {
for (int i = 0; i < n; ++i)
;
return true;
}
static_assert(test_empty_if_consteval(524286));
static_assert(test_empty(1048572));
static_assert(test_empty_if_consteval(524287)); // fails by default
static_assert(test_empty(1048573)); // fails by default
```
If I understood correctly, the standard treats "full-expressions evaluated within a core constant _expression_" as the implementation-defined limit ([[expr.const]/9.7](https://eel.is/c++draft/expr.const#9.7), [[implimits]/1.39](https://eel.is/c++draft/implimits#1.39)), and neither `if consteval {}` nor `;` contains any full-_expression_ ([[stmt.if]/4](https://eel.is/c++draft/stmt.if#4), [[intro.execution]/5](https://eel.is/c++draft/intro.execution#5)). So it seems to me that there shouldn't be any difference on constant evaluation limits between `if consteval {}` and `;`.
Is such difference intended? If so, perhaps we should amend the standard wording to permit our strategy.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs