Skip to content

Byte-operator lowering: add support pointer types in adjust_width#8892

Open
tautschnig wants to merge 1 commit intodiffblue:developfrom
tautschnig:fix-8475-adjust-width
Open

Byte-operator lowering: add support pointer types in adjust_width#8892
tautschnig wants to merge 1 commit intodiffblue:developfrom
tautschnig:fix-8475-adjust-width

Conversation

@tautschnig
Copy link
Copy Markdown
Collaborator

Add support for ID_pointer type in adjust_width function to handle byte extraction from pointer arrays correctly.

Fixes: #8475

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@tautschnig tautschnig self-assigned this Mar 26, 2026
The adjust_width function in lower_byte_operators.cpp did not handle
the ID_pointer type. When CBMC processes byte extraction operations
on data involving pointers, it may need to create bitvector types from
the pointer type. Since pointers were not supported, the function
would hit the PRECONDITION(false) fallthrough case.

Add support for ID_pointer type by returning bv_typet, consistent
with how pointers are treated elsewhere in the byte-operator lowering
code (e.g., in unpack_rec).

Add a unit test that directly verifies adjust_width handles pointer
types, plus additional unit tests for byte extraction involving
pointer types and arrays of pointers.

Fixes: diffblue#8475

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@tautschnig tautschnig force-pushed the fix-8475-adjust-width branch from 2bb57a7 to 9c2f8cd Compare March 26, 2026 17:35
@tautschnig tautschnig marked this pull request as ready for review March 26, 2026 17:41
Copilot AI review requested due to automatic review settings March 26, 2026 17:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a crash in the byte-operator lowering logic by teaching adjust_width how to handle pointer-typed bitvectors, which can arise when lowering byte_extract/byte_update involving pointers (including arrays of pointers).

Changes:

  • Extend adjust_width to accept ID_pointer and return a resized bitvector type instead of failing a precondition.
  • Add unit/regression tests covering adjust_width on pointers and lower_byte_extract on pointer and array-of-pointer result types.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/util/lower_byte_operators.cpp Allows pointer-typed widths to be adjusted without triggering a PRECONDITION(false) during lowering.
unit/util/lower_byte_operators.cpp Adds regression coverage for pointer handling in adjust_width and for lowering byte_extract producing pointer/array-of-pointer types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.42%. Comparing base (59d2211) to head (9c2f8cd).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8892   +/-   ##
========================================
  Coverage    80.41%   80.42%           
========================================
  Files         1703     1703           
  Lines       188398   188443   +45     
  Branches        73       73           
========================================
+ Hits        151502   151549   +47     
+ Misses       36896    36894    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Invariant check failed: src/util/lower_byte_operators.cpp:73 function: adjust_width

2 participants