Skip to content

mk_implicit_cast, process_one: eliminate spurious void cast roundtrips for pointer init#3

Merged
DominicPM merged 1 commit intomainfrom
pointer-cast-simplification
Mar 25, 2026
Merged

mk_implicit_cast, process_one: eliminate spurious void cast roundtrips for pointer init#3
DominicPM merged 1 commit intomainfrom
pointer-cast-simplification

Conversation

@DominicPM
Copy link
Copy Markdown
Owner

Two fixes for combined pointer declaration+initialization from struct fields (e.g. int16_t *r = p->coeffs;) generating unnecessary c_cast_to_void/c_cast_from_void roundtrips that the separate declaration+assignment path avoids:

  1. mk_implicit_cast: in the T*->U* reinterpret case, skip the void roundtrip when both inner types have the same HOL representation (catches CLong/CLongLong on LP64, typedef-resolved variants, etc.)

  2. process_one (CInitExpr0): for pointer init from array-backed struct fields, skip mk_implicit_cast entirely — matching the separate assignment path which binds the RHS directly without any cast. Guarded by alias_list_backed to ensure alias storage is used.

…s for pointer init

Two fixes for combined pointer declaration+initialization from struct
fields (e.g. `int16_t *r = p->coeffs;`) generating unnecessary
c_cast_to_void/c_cast_from_void roundtrips that the separate
declaration+assignment path avoids:

1. mk_implicit_cast: in the T*->U* reinterpret case, skip the void
   roundtrip when both inner types have the same HOL representation
   (catches CLong/CLongLong on LP64, typedef-resolved variants, etc.)

2. process_one (CInitExpr0): for pointer init from array-backed struct
   fields, skip mk_implicit_cast entirely — matching the separate
   assignment path which binds the RHS directly without any cast.
   Guarded by alias_list_backed to ensure alias storage is used.
@DominicPM DominicPM self-assigned this Mar 25, 2026
@DominicPM DominicPM added the bug Something isn't working label Mar 25, 2026
@DominicPM DominicPM merged commit 416c810 into main Mar 25, 2026
9 checks passed
@DominicPM DominicPM deleted the pointer-cast-simplification branch March 25, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant