Skip to content

Fix and test signed/unsigned comparison semantics #1001

@inducer

Description

@inducer

There's the classical C footgun:

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.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions