Skip to content

No narrowing warning where the other side of the conversion is a C declaration (#2261) - #3446

Merged
ehartford merged 3 commits into
mainfrom
c-boundary-narrowing
Nov 18, 2026
Merged

ehartford merged 3 commits into
mainfrom
c-boundary-narrowing

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Closes #2261. Ruled 2026-11-18: rule A, widened.

D183 made an integer that meets a narrower or differently signed declaration convert with a range check, and a warning names the declaration to widen. At a C boundary both of the warning's fixes are wrong: the declaration is the header's, and as removes the check.

  • The warning is not issued when the declaration on the other side of the conversion was imported from C: an argument of a C function, a C function's result, a field of a C record (read or written), a C global (read or written, through unsafe { } too).
  • The range check is unchanged in every case.
  • A migrated module keeps its seam warning (D156): there the two widths are a data model's and the host's, which is the fact that warning reports.
  • The warning still fires where the narrower declaration is the program's own.
  • Spec v7.64: one sentence in §4.2.6. D108's length param N follow-on is recorded as not needed, with the reason.
  • The test runner gains //! expect-build-stderr-not:, so a test can assert that a warning is gone.

Tests: three behaviour tests (the conversions run; the build is quiet at each C boundary; a With declaration still warns).

Battery green on the branch tip.

@ehartford
ehartford merged commit 88efb19 into main Nov 18, 2026
@ehartford
ehartford deleted the c-boundary-narrowing branch November 18, 2026 23:46
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.

Facade clause length param N: a count parameter takes a non-negative isize without a spelled cast (D51-shaped)

1 participant