[clang] [Clang] use constant evaluation context for constexpr if conditions (PR #123667)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 24 22:44:34 PST 2025


================
@@ -977,6 +977,7 @@ Bug Fixes to C++ Support
 - Fix immediate escalation not propagating through inherited constructors.  (#GH112677)
 - Fixed assertions or false compiler diagnostics in the case of C++ modules for
   lambda functions or inline friend functions defined inside templates (#GH122493).
+- Clang now permits the use of immediate-escalating expressions in ``constexpr`` if conditions. (#GH123524)
----------------
zyn0217 wrote:

If possible, I'd like to ask you to consolidate the note with line 977.

AFAIK this isn't the first time we start to allow the use of immediate functions within `if constexpr` statements. For example, we've already been accepting code like this

```cpp
consteval bool fn() {
  return true;
}

void fn2() {
    if constexpr (fn()) {}
}

```

So the phrase "now permits" is inaccurate in these scenarios

https://github.com/llvm/llvm-project/pull/123667


More information about the cfe-commits mailing list