From c15d1c6e7ed192c36dff960792319f964373eb6b Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 3 Jun 2022 20:53:10 +0300 Subject: [PATCH] cgen,ci: fix cast_bool_to_int_test.v on windows-tcc --- vlib/v/gen/c/cgen.v | 4 ++-- vlib/v/tests/cast_bool_to_int_test.v | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index fff9170f6a..b284ba72b6 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -3961,9 +3961,9 @@ fn (mut g Gen) cast_expr(node ast.CastExpr) { g.expr(node.expr) } else if node.expr_type == ast.bool_type && node.typ.is_int() { styp := g.typ(node.typ) - g.write('($styp)(') + g.write('($styp[]){(') g.expr(node.expr) - g.write(')') + g.write(')?1:0}[0]') } else { styp := g.typ(node.typ) if (g.pref.translated || g.file.is_translated) && sym.kind == .function { diff --git a/vlib/v/tests/cast_bool_to_int_test.v b/vlib/v/tests/cast_bool_to_int_test.v index 2158366fdd..a34d20f910 100644 --- a/vlib/v/tests/cast_bool_to_int_test.v +++ b/vlib/v/tests/cast_bool_to_int_test.v @@ -2,6 +2,10 @@ module main fn test_cast_bool_to_int() { i := true + x := int(i) + nx := int(!i) + dump(x) + dump(nx) a := [1, 2, 3] println(a[int(!i)])