zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 83fc754af76a4589934550af9be3534af2df5bc9 (tree)
parent 564c858bd45400b6723637286081cc1bbb0df214
Author: Motiejus <motiejus@jakstys.lt>
Date:   Sat,  7 Mar 2026 07:32:49 +0000

sema: fix cppcheck unreadVariable in zirCmpEq

The coerce calls create IP side effects; comparison uses captured
lhs_lo/rhs_lo values. Use (void)semaCoerce() to make intent explicit.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

Diffstat:
Mstage0/sema.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/stage0/sema.c b/stage0/sema.c @@ -1326,8 +1326,10 @@ static AirInstRef zirCmpEq( TypeIndex result_ty = (lhs_ty == IP_INDEX_COMPTIME_INT_TYPE) ? rhs_ty : lhs_ty; if (result_ty != IP_INDEX_COMPTIME_INT_TYPE) { - lhs = semaCoerce(sema, block, result_ty, lhs); - rhs = semaCoerce(sema, block, result_ty, rhs); + // Coerce for IP side effects (creates typed int entries); + // comparison uses captured lhs_lo/rhs_lo values. + (void)semaCoerce(sema, block, result_ty, lhs); + (void)semaCoerce(sema, block, result_ty, rhs); } bool eq = (lhs_lo == rhs_lo && lhs_hi == rhs_hi); return AIR_REF_FROM_IP((eq == (air_tag == AIR_INST_CMP_EQ))