Skip to content
Back to formatted view

Raw Message

Message-ID: <CALECgPaop1dk_Zfxrb-68sJkFfUPtBJ6FHkqMAuNTKbA+t=zPg@mail.gmail.com>
Date: 2024-12-11T12:12:11Z
From: Brad Eck
Subject: [R-pkg-devel] truncating strings on purpose

Dear List

The latest update to my epanet2toolkit package bounced from CRAN due to
some warnings about string truncation in C code from gcc.

Found the following significant warnings:
    input2.c:863:5: warning: ?__builtin_strncpy? output may be truncated
copying 225 bytes from a string of length 255 [-Wstringop-truncation]
    input2.c:302:15: warning: ?__builtin_strncpy? output may be truncated
copying 78 bytes from a string of length 1024 [-Wstringop-truncation]
    report.c:795:9: warning: ?__builtin_strncpy? output may be truncated
copying 967 bytes from a string of length 1024 [-Wstringop-truncation]

The package wraps a simulation engine that parses inputs from and
writes results to text files. Where the truncation warnings appear, I
am truncating on purpose using `strncpy` to avoid overflows later.  I
believe this works fine from an application point of view but the
warnings remain.

Any suggestions on how to carry out a truncation so that gcc won't
complain?

Thanks in advance,

Brad

PS - CRAN check info is here
https://win-builder.r-project.org/incoming_pretest/epanet2toolkit_1.0.6_20241209_221743/specialChecks/

PPS the latest CRAN submission is from this branch
https://github.com/bradleyjeck/epanet2toolkit/tree/lto-crash

	[[alternative HTML version deleted]]