Closed JonathanFoo0523 closed 1 month ago
The obvious thing to do here would be to remove static assertions, by replacing them with nothing, or by replacing their expressions with 1
. There is no point rewriting them (like for constant-sized arrays), because if their expressions evaluated to 0
then the front-end used by Dredd would have already failed.
A concern I have is that static assertions are rather likely to appear in header files or macros (when used in header-file libraries). Because Dredd deliberately does not mutate header files, this could be a problem if constants used in such assertions have their initial values mutated.
On balance I think it may be cleanest to rewrite static asserts, since this will be being done for __builtin_frame_address
in #289. @JonathanFoo0523 are you happy to take care of this along with #289?
Seems like it is not possible to rewrite expression under static_assert
to the actual expression anyway. For example,
int main() {
const int a = 42;
static_assert(a);
}
The a
always evaluate to 1
instead of 42
.
I will just rewrite to 1
without actually evaluating, as mentioned in above comment.
Dredd mutate the C++ program
to
which lead to compilation error: