Fix arch-dependent integer overflow in gage_validate for single-point timeseries#81
Draft
Copilot wants to merge 2 commits into
Draft
Fix arch-dependent integer overflow in gage_validate for single-point timeseries#81Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
…arm64 When a timeseries has only a single data point, table_validate() leaves dxMin as BIG (1e10). Casting BIG*SECperDAY to int overflows and produces architecture-dependent results: negative on x86-64 (passes the check), positive on arm64 (fails the check and emits a spurious WARN09). Fix by skipping the interval comparison when dxMin is BIG, since a single-point timeseries has no meaningful minimum interval to compare against.
Copilot
AI
changed the title
[WIP] Fix overflow issue when compiling SWMM on arm64 architecture
Fix arch-dependent integer overflow in gage_validate for single-point timeseries
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a rain gage timeseries has only one data point,
table_validate()never updatesdxMinfrom its initial sentinel value ofBIG(1×10¹⁰). CastingBIG * SECperDAY(~8.64×10¹⁴) tointoverflows — negatively on x86-64 (silently passes the check) but positively on arm64 (spuriously triggers WARN09 about recording interval).Change
src/solver/gage.c—gage_validate(): Guard thegageIntervalcomputation and interval comparison checks behindif ( Tseries[k].dxMin < BIG ). A single-point timeseries has no meaningful minimum interval, so the checks are correctly skipped rather than relying on undefined overflow behavior.