Skip to content

compiler: require a non-negative interrupt ID - #6848

Open
davecheney wants to merge 1 commit into
devfrom
interrupt-negative-id
Open

davecheney wants to merge 1 commit into
devfrom
interrupt-negative-id

Conversation

@davecheney

Copy link
Copy Markdown
Contributor

The compiler already required a constant ID for interrupt.New, but it accepted a negative constant without a diagnostic. On pico, a program that called interrupt.New(-1, handler) and then Enable compiled to an unconditional call to runtime.lookupPanic. ClearPendingIRQ indexed the [8] NVIC.ICPR array with 0x7FFFFFF. With this change, the compiler adds a second constraint to the interrupt.New ID. The ID must be a constant and must not be negative. For a negative constant, the compiler reports "interrupt ID must not be negative" at the call.

@davecheney
davecheney added this pull request to stack #6850 December 4, 2026 23:07
The compiler already required a constant ID for interrupt.New, but it accepted a negative constant without a diagnostic. On pico, a program that called interrupt.New(-1, handler) and then Enable compiled to an unconditional call to runtime.lookupPanic. ClearPendingIRQ indexed the [8] NVIC.ICPR array with 0x7FFFFFF. With this change, the compiler adds a second constraint to the interrupt.New ID. The ID must be a constant and must not be negative. For a negative constant, the compiler reports "interrupt ID must not be negative" at the call.
@davecheney
davecheney force-pushed the interrupt-negative-id branch from 8c8592e to 32a2f12 Compare December 5, 2026 21:53
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.

1 participant