inducer / inducer/loopy

Fix and test signed/unsigned comparison semantics

Open
#1,001 0 comments 1 reaction 2 assignees Claimed by @inducer View on GitHub
Dominant language
Python
Stars
636
Forks
81
Avg merge
1d 19h
Merged PRs (30d)
7

Description

There's the classical C footgun:
```c
int x = -1;
unsigned int y = 1;
if (x < y) { ... } // branch NOT taken — x converts to UINT_MAX
```
We're currently subject to this behavior, which isn't consistent with Python semantics (which we otherwise try to follow). Tweak `map_comparison` in `ExpressionToCExpressionMapper` in `loopy/target/c/codegen/expression.py` to treat mixed-signedness comparisons correctly. Add exhaustive tests. Also cover mixed-signedness subtraction.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.