From 68000c01ae5b90a4b9677f7725a286e9057e9767 Mon Sep 17 00:00:00 2001 From: herman ten brugge Date: Mon, 30 Dec 2024 07:31:16 +0100 Subject: [PATCH] Print correct values for testcase 134 on all targets Testcase 134 only worked on x86_64 and i386 not on other targets. --- tccgen.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tccgen.c b/tccgen.c index 315a3a2d2..b7d35ba7a 100644 --- a/tccgen.c +++ b/tccgen.c @@ -3251,8 +3251,12 @@ static void gen_cast(CType *type) } else if (sf && dbt == VT_BOOL) { vtop->c.i = (vtop->c.ld != 0); } else { - if(sf) - vtop->c.i = vtop->c.ld; + if(sf) { + if (dbt & VT_UNSIGNED) + vtop->c.i = (uint64_t)vtop->c.ld; + else + vtop->c.i = (int64_t)vtop->c.ld; + } else if (sbt_bt == VT_LLONG || (PTR_SIZE == 8 && sbt == VT_PTR)) ; else if (sbt & VT_UNSIGNED)