I realize that the order of parameter evaluation of a function call is not guaranteed to be one way or the other. But, is there a good reason that GCC has a different ordering when in a constexpr
context? The example below can be set to fail either at run-time or compile-time.
#include <vector>
#include <cassert>
// #define WORK_IN_CONSTEXPR // <-- Toggle comment to fail at run-time instead
constexpr bool check() {
std::vector<int> v{1,2};
#ifdef WORK_IN_CONSTEXPR
assert(v.erase(v.begin() + 1) == v.end()); // <-- This only passes in constexpr
#else
assert(v.end() == v.erase(v.begin() + 1)); // <-- This only passes at run-time
#endif
return true;
}
static_assert(check());
int main() {
return !check();
}
12