For the macro-lovers, it's possible to define an immediately invoked lambda:Rein Halbersma wrote: ↑Wed Sep 14, 2022 10:39 pm But this wasn't the OP's question. Simply initializing a constexpr variable inside foo() and then returning that, will simplify the program at -O0 already. https://gcc.godbolt.org/z/d8YzshsTW
Code: Select all
#define FORCE_CONSTEXPR(expr) [&]() \
{ constexpr auto x = (expr); return x; }()
Code: Select all
if (x & FORCE_CONSTEXPR((Rank6 | Rank7 | Rank8)))