Closed
Description
constexpr int a() {
int a = 0;
[[assume(++a)]];
return a;
}
static_assert(a() == 1);
#include <iostream>
int main() {
std::cout << a() << "\n";
}
This code prints 0
, even though the static_assert
doesn't fail. Clang does print a warning about the side-effects of ++a
being discarded, but that is not true at compile time.
CC @Sirraide