rust-lang / rust-lang/rustc_codegen_gcc

Make sure `offset(0)` is handled correctly

Open
#515 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

libgccjit
Dominant language
Rust
Stars
1.2k
Forks
105
Avg merge
8h 20m
Merged PRs (30d)
14

Description

The offset intrinsic (called inbounds_gep in the codegen_ssa API) is now always defined when the offset is 0, even if the pointer is 0 or dangling.

The GCC backend uses new_array_access to model that; it is important to make sure that if the index is 0, this is never UB.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the GCC backend's new_array_access handling of the offset intrinsic, called inbounds_gep in the codegen_ssa API. Check the zero-index path, including null or dangling pointers, and add or update coverage so offset(0) is never treated as undefined behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.