oxidecomputer / oxidecomputer/p4

Add compiler warning for preprocessor replacement within integer literals

Open
#3 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

diagnostics
Dominant language
Rust
Stars
137
Forks
12
Avg merge
4d 22h
Merged PRs (30d)
3

Description

From this Stack Overflow thread

Similar considerations mean that _ can't be used either; if there is a #define _234 * 2, then a[1_234] would silently change the meaning of the code.

As _ is the integer literal separator in p4, this silent code modification could sneak up and bite someone. We should detect and emit a warning here.

Contributor guide

No contributing guide indexed for this repository

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 compiler's preprocessor replacement handling and integer-literal parsing, using the linked Stack Overflow example as the behavioral context. Determine where a replacement inside an integer literal can be detected, then verify that the compiler emits a warning for this case without silently changing the source meaning.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
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.