lab2 feat: prevent division by zero in non-folded operations
This commit is contained in:
@@ -6,3 +6,4 @@
|
|||||||
#define MAX_TOKEN_STRING_LEN 256
|
#define MAX_TOKEN_STRING_LEN 256
|
||||||
|
|
||||||
#define LAB2_EXCLUDE_COMPTIME_OP_WRITES 1
|
#define LAB2_EXCLUDE_COMPTIME_OP_WRITES 1
|
||||||
|
#define LAB2_PREVENT_NON_FOLDED_DIV_BY_ZERO 1
|
||||||
|
|||||||
@@ -334,6 +334,13 @@ static int write_operation(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
|
#if LAB2_PREVENT_NON_FOLDED_DIV_BY_ZERO == 1
|
||||||
|
if (r.t == Expression::Token::CONST && r.v.d == 0.0 && o.v.o == Expression::Token::DIV)
|
||||||
|
{
|
||||||
|
pr_warn("Right operand is zero, operation will raise exception during runtime");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
int this_op_weight = get_operator_weight(mv, location) + 1;
|
int this_op_weight = get_operator_weight(mv, location) + 1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user