mc-imperial / dredd

Framework for evaluating C/C++ compiler testing tools
Apache License 2.0
11 stars 3 forks source link

Avoid mutation constexpr specified functions #234

Closed JamesLee-Jones closed 3 months ago

JamesLee-Jones commented 3 months ago

We cannot mutate functions that are specified as constexpr as Dredd's mutations occur dynamically and constexpr functions require compile time evaluation.

Fixes: #233.

JamesLee-Jones commented 3 months ago

then would we expect the call to "Max(5,4)" to get mutated, because although it is a constexpr, it is not being returned in a constexpr context?

Would you be able to have a look at that, and if the call to Max does get mutated add another single file test case to demonstrate it?

In this case, the call to Max does get mutated as we would expect, producing:

# Dredd prelude

constexpr int Max(int a, int b) { return a > b ? a : b; }

int foo() {
  if (!__dredd_enabled_mutation(15)) { return __dredd_replace_expr_int_constant([&]() -> int { return Max(__dredd_replace_expr_int_constant(5, 0),__dredd_replace_expr_int_constant(4, 5)); }, 10); }
}

So I'll add another test case.