On Tue May 9 10:35:56 2023 +0000, Giovanni Mascellani wrote:
This is undefined behavior on `INT_MIN`. Actually, this case is somewhat interesting, because `lower_int_abs()` runs before constant expression folding, and should get rid of all `int` absolute values. So in principle we could stick `vkd3d_unreachable()` here. However `lower_int_abs()` does not run when doing constant folding from `evaluate_static_expression_as_uint()`, so this is still reachable. I'm not sure of what the others think, but I think I would be in favor to stipulating that this is unreachable and add other passes to `evaluate_static_expression_as_uint()`.
I could see this getting hit again if fold_exprs got used elsewhere - if we can't fold abs(INT_MIN), would it make sense to leave the expression untouched and let the runtime deal with it instead? I can add a quick
``` /* abs(INT_MIN) is undefined, leave this expression alone */ if (src->value.u[k].i == INT_MIN) return false; ```
if so.