Skip to content

Conversation

jserv
Copy link
Collaborator

@jserv jserv commented Sep 5, 2025

This commit resolves the long-standing limitation where non-char pointer differences didn't work correctly. The root cause was incorrect ARM instruction encoding for arithmetic right shift, not a parser issue.

The fix enables proper pointer differences for all types:

  • Integer pointers (int*)
  • Struct pointers
  • Typedef pointers
  • Complex pointer expressions

Summary by cubic

Fixes pointer arithmetic across all pointer types by correcting ARM SRA encoding and unifying pointer arithmetic in the parser. Pointer differences now return element counts for int*, struct*, typedef pointers, and complex expressions.

  • Bug Fixes
    • Corrected ARM arithmetic right shift (register-based) instruction encoding.
    • Unified pointer arithmetic: detects pointer–pointer difference, scales by element size, and preserves pointer type metadata.
    • Expanded tests to cover int/char/struct/typedef pointers, negative and zero differences, array indexing, and complex expressions.

This commit resolves the long-standing limitation where non-char pointer
differences didn't work correctly. The root cause was incorrect ARM
instruction encoding for arithmetic right shift, not a parser issue.

The fix enables proper pointer differences for all types:
- Integer pointers (int*)
- Struct pointers
- Typedef pointers
- Complex pointer expressions
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

@jserv jserv merged commit 56c9378 into master Sep 5, 2025
13 checks passed
@jserv jserv deleted the pointer-arithmetic branch September 5, 2025 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant