[clang] [clang] The ms-extension __noop should return zero in a constexpr context. (PR #106849)

Mital Ashok via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 31 09:48:27 PDT 2024


MitalAshok wrote:

Could you also add tests that calling it returns zero and doesn't evaluate its arguments:

```c++
static_assert([]{ return __noop(4); }() == 0);
extern int not_accessed;
void not_called();
static_assert([]{ return __noop(not_accessed *= 6); }() == 0);
static_assert([]{ return __noop(not_called()); }() == 0);
static_assert([]{ return __noop(throw ""); }() == 0);
static_assert([]{ return __noop(throw "", throw ""); }() == 0);
static_assert([]{ int a = 5; __noop(++a); return a; }() == 5);
```

This passes on MSVC (<https://godbolt.org/z/nvxr3GxT4>) but currently crashes Clang.


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


More information about the cfe-commits mailing list