From 80703f27a5caa8eae9879f6786fd9cb9edd1735b Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 11 Nov 2021 22:50:35 +0800 Subject: [PATCH] Codegen C - Fix incorrect handling of `ctlz` with `usize` on 32-bit platforms (ref #78) --- src/trans/codegen_c.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index e9f2dbffe..c0f07925e 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -6172,7 +6172,7 @@ namespace { m_of << ");"; return ; } - else if( ty == ::HIR::CoreType::U64 || (ty == ::HIR::CoreType::Usize /*&& target_is_64_bit */) ) + else if( ty == ::HIR::CoreType::U64 || (ty == ::HIR::CoreType::Usize && Target_GetPointerBits() > 32) ) { emit_param(e.args.at(0)); m_of << " != 0 ? "; if( name == "ctlz" || name == "ctlz_nonzero" ) {