diff --git a/config.h b/config.h index 334a266..8747f64 100644 --- a/config.h +++ b/config.h @@ -6,3 +6,4 @@ #define MAX_TOKEN_STRING_LEN 256 #define LAB2_EXCLUDE_COMPTIME_OP_WRITES 1 +#define LAB2_PREVENT_NON_FOLDED_DIV_BY_ZERO 1 diff --git a/src/syntaxer.cpp b/src/syntaxer.cpp index a4ad568..de1d372 100644 --- a/src/syntaxer.cpp +++ b/src/syntaxer.cpp @@ -334,6 +334,13 @@ static int write_operation( } 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 int this_op_weight = get_operator_weight(mv, location) + 1;