Ver código fonte

[cpp] Fix divide by constant 0 check. For #662

hughsando 7 anos atrás
pai
commit
25f69f6f34
1 arquivos alterados com 2 adições e 1 exclusões
  1. 2 1
      src/generators/gencpp.ml

+ 2 - 1
src/generators/gencpp.ml

@@ -3294,10 +3294,11 @@ let cpp_gen_default_values ctx args prefix =
    ) args;
    ) args;
 ;;
 ;;
 
 
-let is_constant_zero expr =
+let rec is_constant_zero expr =
   match expr.cppexpr with
   match expr.cppexpr with
   | CppFloat x when (float_of_string x) = 0.0 -> true
   | CppFloat x when (float_of_string x) = 0.0 -> true
   | CppInt i when i = Int32.of_int 0 -> true
   | CppInt i when i = Int32.of_int 0 -> true
+  | CppCastScalar(expr,_) -> is_constant_zero(expr)
   | _ -> false
   | _ -> false
 ;;
 ;;