Skip to content

Fix arch-dependent integer overflow in gage_validate for single-point timeseries#81

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-overflow-issue-arm64
Draft

Fix arch-dependent integer overflow in gage_validate for single-point timeseries#81
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-overflow-issue-arm64

Conversation

Copy link
Copy Markdown

Copilot AI commented May 28, 2026

When a rain gage timeseries has only one data point, table_validate() never updates dxMin from its initial sentinel value of BIG (1×10¹⁰). Casting BIG * SECperDAY (~8.64×10¹⁴) to int overflows — negatively on x86-64 (silently passes the check) but positively on arm64 (spuriously triggers WARN09 about recording interval).

Change

  • src/solver/gage.cgage_validate(): Guard the gageInterval computation and interval comparison checks behind if ( 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.
// Before: always computed, overflows for single-point timeseries
gageInterval = (int)(floor(Tseries[k].dxMin*SECperDAY + 0.5));
if ( gageInterval > 0 && Gage[j].rainInterval > gageInterval ) { ... }
if ( Gage[j].rainInterval < gageInterval ) { /* spurious WARN09 on arm64 */ }

// After: skip entirely when dxMin was never updated from BIG
if ( Tseries[k].dxMin < BIG )
{
    gageInterval = (int)(floor(Tseries[k].dxMin*SECperDAY + 0.5));
    if ( gageInterval > 0 && Gage[j].rainInterval > gageInterval ) { ... }
    if ( Gage[j].rainInterval < gageInterval ) { ... }
}

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 28, 2026

CLA assistant check
All committers have signed the CLA.

…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
Copilot AI requested a review from cbuahin May 28, 2026 07:25
@cbuahin cbuahin closed this May 29, 2026
@cbuahin cbuahin reopened this May 29, 2026
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.

Overflow issue when compiling SWMM on arm64 architecture

3 participants