Heads up: new const warnings from strchr with gcc 16
Gary E. Miller
gem at rellim.com
Thu Mar 12 04:00:54 UTC 2026
Yo Hal!
On Wed, 11 Mar 2026 20:24:12 -0700
Hal Murray via devel <devel at ntpsec.org> wrote:
> Fedora 44-Alpha is out. It's got gcc 16 which is now "smart" enough
> to generate a new warning.
You, that hit gpsd as well.
> If you pass in a const string, the compiler figures out that the
> answer is pointing into that string so the result should really be a
> const.
Yes.
> I fixed a few simple cases. I haven't fixed this one.gcc
> char *cpw = strchr(cp, '\r')
Isn't the fix simply:
const char *cpw = strchr(cp, '\r')
As you said, since "cp" is (const char *0 then cpw must also be.
Kinda nice error actually.
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
gem at rellim.com Tel:+1 541 382 8588
Veritas liberabit vos. -- Quid est veritas?
"If you can't measure it, you can't improve it." - Lord Kelvin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 283 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ntpsec.org/pipermail/devel/attachments/20260311/4ff76002/attachment.bin>
More information about the devel
mailing list