AI review of 2026-11-16_06-59-34-77ceb53a9ebc-results.txt PR: #9033 https://github.com/cppcheck-opensource/cppcheck/pull/9033 Tested: 77ceb53a9ebcaded784899239bd1bbe07e13457b Merge base: e6188446626b9e3c0cd16ffe0e49c73b18e52793 Reviewed: 2026-11-16 21:52:11 UTC Model: claude-opus-5-5 (effort high) Results: 50 reviewed of 52 in the report (random sample) Verdicts: 26 acceptable regression, 24 improvement Tokens: 77002 input, 64800 cache read, 2700 cache write, 25387 output The verdicts are written by AI and can be wrong. ---- 1 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/b/bbe/bbe_0.2.2.orig.tar.gz Result: main bbe-0.2.2/src/buffer.c:243:20: style: Variable 'safe_search' can be declared as pointer to const [constVariablePointer] Explanation: In the visible code, 'safe_search' is only assigned to and then used read-only: in comparisons (`block_end > safe_search`) and in pointer arithmetic whose result is only compared (`scan <= safe_search - len + 1`). Declaring it `const unsigned char *` would therefore compile, so the original warning looks like a true positive. The PR now stops skipping `-` when the result is a pointer, because a pointer difference could be stored in a non-const pointer. That logic also suppresses this case, even though the result is only compared. The rest of the function is not shown, so medium confidence. ---- 2 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/b/bitlbee/bitlbee_3.6.orig.tar.gz Result: main bitlbee-3.6/protocols/twitter/twitter_lib.c:1039:11: style: Variable 'nl' can be declared as pointer to const [constVariablePointer] Explanation: `nl` only receives the result of `strstr` and is used in `nl - req->reply_body`. That is a pointer difference whose result is an integer, so `nl` is never written through and could be `const char *`. The removed warning was a true positive. The PR now skips the `-` parent only when its valueType is known and non-pointer. Here the valueType of the subtraction is probably unknown, because the type of `req->reply_body` is not resolved, so the variable is now treated as non-const. The result is a new false negative. ---- 3 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/c/cfitsio/cfitsio_4.7.0.orig.tar.gz Result: main cfitsio-4.7.0/imcompress.c:9503:24: style: Variable 'heapptr' can be declared as pointer to const [constVariablePointer] Explanation: In fits_unshuffle_2bytes, 'heapptr' is only read through: '*heapptr', '*(heapptr - length)' and 'heapptr--'. Nothing is ever written through it, and assigning 'heap + ...' to a 'const char*' is valid. So the warning that it can be pointer to const was a true positive. The PR no longer skips a '-' whose result is a pointer, so 'heapptr - length' is now treated as a possible non-const use, even though the result is only dereferenced for reading. That makes this a new false negative, a side effect of fixing the #15219 false positive. ---- 4 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/c/cfitsio/cfitsio_4.7.0.orig.tar.gz Result: main cfitsio-4.7.0/imcompress.c:9528:24: style: Variable 'heapptr' can be declared as pointer to const [constVariablePointer] Explanation: `heapptr` is only used to read data (`*heapptr`, `*(heapptr - length)`, ...) and is itself decremented; nothing is ever written through it. Assigning it from `heap + ...` would also work with `const char *`. So it really could be `const char *`, and the removed warning was a true positive. The PR now always skips the parent `-` when the result is a pointer, even when the result is only dereferenced for reading. That fixes the #15219 false positive but loses this valid warning, a new false negative. ---- 5 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/c/cfitsio/cfitsio_4.7.0.orig.tar.gz Result: main cfitsio-4.7.0/imcompress.c:9557:24: style: Variable 'heapptr' can be declared as pointer to const [constVariablePointer] Explanation: In fits_unshuffle_8bytes, 'heapptr' is assigned from 'heap', which is char*, and is then only read: '*heapptr', '*(heapptr - k*length)' and 'heapptr--'. Nothing is ever written through it, so declaring it 'const char *' is valid, and the removed warning was a true positive. The PR no longer skips a pointer operand of '-' when the result is a pointer. The 'heapptr - length' expressions are now treated as possible non-const uses, so this correct warning is lost (a new false negative). ---- 6 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/c/cpl-plugin-vimos/cpl-plugin-vimos_4.1.7+dfsg.orig.tar.xz Result: main vimos-4.1.7/external/libwcs/tabread.c:1738:11: style: Variable 'endcol' can be declared as pointer to const [constVariablePointer] Explanation: In the visible code, `endcol` is only assigned (`nextab - 1`, `headlast - 1`, `endcol - 1`), dereferenced for reading (`*endcol == ' '`) and used in a pointer difference (`endcol - colhead`). It is never written through, so `const char *endcol` would work and main's warning looks like a true positive. The PR no longer skips a `-` parent whose result is a pointer. That makes `endcol - 1` count as a possible non-const use, even though the result is only stored back into `endcol` itself. So a valid warning is lost: a new false negative caused by the PR's more conservative handling of pointer arithmetic. The rest of the function after line 1778 is not shown, which keeps confidence at medium. ---- 7 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/c/cpl-plugin-vimos/cpl-plugin-vimos_4.1.7+dfsg.orig.tar.xz Result: main vimos-4.1.7/external/libwcs/tabread.c:1741:11: style: Variable 'hyphlast' can be declared as pointer to const [constVariablePointer] Explanation: In libwcs `tabparse`, `hyphlast` is set from `strchr` and, as far as I recall, only used for comparisons and pointer differences such as `hyphlast - colhead` (not shown in the excerpt). It is never written through, so `const char *hyphlast` would be valid and the original warning was a true positive. The PR now skips `-` only when the result's valueType is non-pointer. The pointer-difference result here apparently has no valueType set, so the usage is no longer skipped and the warning disappears. This is a new false negative rather than a fixed false positive. ---- 8 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/c/cpl-plugin-vimos/cpl-plugin-vimos_4.1.7+dfsg.orig.tar.xz Result: main vimos-4.1.7/vimos/vmmath.c:1694:16: style: Variable 'v' can be declared as pointer to const [constVariablePointer] Explanation: `v` is a `float*` returned as `v-nl+NR_END` from a function whose return type is `float*`. Declaring `v` as `const float*` would not compile without a cast, so the constVariablePointer warning was a false positive. The PR stops skipping pointer arithmetic with '-', which removes it. ---- 9 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/c/cpl-plugin-vimos/cpl-plugin-vimos_4.1.7+dfsg.orig.tar.xz Result: main vimos-4.1.7/vimos/vmmatrix.c:533:8: style: Variable 'v' can be declared as pointer to const [constVariablePointer] Explanation: `v` is returned as `v-nlow+RANGE_END` from a function whose return type is `int *`. Declaring `v` as `const int *` would not compile without a cast, so the old constVariablePointer warning was a false positive. The PR stops skipping pointer subtraction (`-` that yields a pointer), so this pointer arithmetic is no longer treated as a read-only use, which removes the false positive. ---- 10 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/c/cpl-plugin-vimos/cpl-plugin-vimos_4.1.7+dfsg.orig.tar.xz Result: main vimos-4.1.7/vimos/vmmatrix.c:560:10: style: Variable 'v' can be declared as pointer to const [constVariablePointer] Explanation: floatVector() returns `v-nlow+RANGE_END`, a `float*` derived from `v`, as a non-const `float*`. If `v` were declared `const float*`, the return would not compile without a cast. So the constVariablePointer warning was a false positive. The PR now skips '-' only when the result is not a pointer, so pointer arithmetic results are tracked and the false positive is gone. ---- 11 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/c/cpl-plugin-vimos/cpl-plugin-vimos_4.1.7+dfsg.orig.tar.xz Result: main vimos-4.1.7/vimos/vmmatrix.c:577:11: style: Variable 'v' can be declared as pointer to const [constVariablePointer] Explanation: In doubleVector, 'v' is used in 'return v-nlow+RANGE_END;', and the function returns 'double *'. If 'v' were declared 'const double *', the result would be 'const double *', which cannot be returned as 'double *' without a cast. The constVariablePointer warning was therefore a false positive. Main skipped every '-' parent, even when the subtraction still yields a pointer. The PR now skips '-' only when the result is not a pointer, so this false positive is gone. ---- 12 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/c/cpl-plugin-vimos/cpl-plugin-vimos_4.1.7+dfsg.orig.tar.xz Result: main vimos-4.1.7/vimos/vmmatrix.c:698:30: style: Parameter 'a' can be declared as pointer to const [constParameterPointer] Explanation: `a - ncl` is assigned to `m[nrl]`, which is a non-const `float*`. The rows of the returned `float**` give write access to the memory `a` points to. Declaring `a` as `const float*` would not compile without a cast, so the old warning was a false positive. The PR stops skipping pointer-arithmetic `-` and now follows the result, which correctly removes this warning. ---- 13 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/f/fungw/fungw_1.2.2.orig.tar.bz2 Result: main fungw-1.2.2/scconfig/src/tmpasm/tmpasm_scconfig.c:272:41: style: Variable 'end' can be declared as pointer to const [constVariablePointer] Explanation: `end` is assigned `buff + strlen(buff)` and, in the code shown, is only read in `end - eopat[0]+1`. That is a pointer difference with an integer result, so `end` could be `const char *` and the old warning looks like a true positive. The PR now skips `-` only when the result's valueType is known to be a non-pointer. `eopat` probably comes from a regex header Cppcheck did not resolve, so the `-` node has no valueType and the usage is no longer treated as const-safe, which drops the warning. The rest of the function is not shown, so a later non-const use of `end` cannot be fully ruled out. Most likely this is a lost true positive, i.e. a new false negative. ---- 14 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/f/furnace/furnace_0.6.8.3+git20261108+ds.orig.tar.xz Result: main furnace-0.6.8.3+git20261108+ds/extern/lame/libmp3lame/psymodel.c:1412:50: style: Parameter 'percep_MS_entropy' can be declared as const array [constParameter] Explanation: In LAME's L3psycho_anal_vbr, `percep_MS_entropy` is written through an alias pointer created by pointer arithmetic (e.g. `ppe = percep_MS_entropy - 2;` followed by `ppe[chn] = ...`). The parameter is modified, so the 'can be declared as const array' warning was a false positive. Before the PR, the checker skipped any `-` parent, so this pointer-producing subtraction was not treated as aliasing. The PR now only skips `-` when the result is not a pointer, so the pointer alias is recognised and the false positive goes away. This matches the PR's own test case `int* q = s - 1;`. ---- 15 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/f/furnace/furnace_0.6.8.3+git20261108+ds.orig.tar.xz Result: main furnace-0.6.8.3+git20261108+ds/extern/libogg/src/framing.c:644:18: style: Variable 'next' can be declared as pointer to const [constVariablePointer] Explanation: In libogg's ogg_sync_pageseek, 'next' is assigned from memchr() or from oy->data+oy->fill. As far as I recall the upstream code (it is not shown in the excerpt), it is otherwise only used in pointer differences: (int)(next-oy->data) and -(next-page). Nothing is ever written through it, so it could be declared 'const unsigned char *', and the warning was a true positive. The PR now skips a '-' parent only when its valueType is a non-pointer. Here the pointer-difference expression apparently has no valueType, or is not recognised as an integer, so the check no longer skips the subtraction, and the valid warning is lost. That is a new false negative. ---- 16 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/f/furnace/furnace_0.6.8.3+git20261108+ds.orig.tar.xz Result: main furnace-0.6.8.3+git20261108+ds/extern/mpg123/src/playlist.c:509:12: style: Variable 'in_line' can be declared as pointer to const [constVariablePointer] Explanation: `in_line` is only read: `in_line[1] != 0`, `++in_line`, and `in_line - pl.linebuf.p`. Nothing is ever written through it, and `strchr`'s `char*` result converts to `const char*` without problems. So the warning was a true positive. The PR now only skips `-` when the result has a known non-pointer valueType. Here that check apparently fails (the valueType of the pointer difference is likely missing), so the subtraction counts as a non-const use and the valid warning is lost. ---- 17 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/h/hylafax/hylafax_6.0.7.orig.tar.gz Result: main hylafax-6.0.7/regex/regcomp.c:1152:17: style: Variable 'top' can be declared as pointer to const [constVariablePointer] Explanation: `top` is only used in the comparison `cs == top-1`. It is never written through and never passed anywhere that needs a non-const pointer. Declaring it `const cset *top` is valid C, because comparing a `cset*` with a `const cset*` is allowed. So the old warning was a true positive. The PR stops skipping `-` when the result is a pointer, which fixes the #15219 case where `s - 1` escapes into a non-const variable. Here the pointer result `top-1` only feeds a comparison, so this true positive is now lost as a false negative. ---- 18 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/i/insighttoolkit4/insighttoolkit4_4.13.3withdata-dfsg2.orig.tar.gz Result: main insighttoolkit4-4.13.3withdata-dfsg2/Modules/ThirdParty/OpenJPEG/src/openjpeg/dwt.c:387:26: style: Variable 'l_cur_res' can be declared as pointer to const [constVariablePointer] Explanation: `l_cur_res` is used in `l_last_res = l_cur_res - 1;`, and `l_last_res` is a non-const `opj_tcd_resolution_t *`. Declaring only `l_cur_res` as pointer to const would make that assignment discard the const qualifier, which is a constraint violation in C. The old warning was therefore misleading when taken on its own. This is exactly the pattern the PR fixes (#15219): pointer subtraction whose result is a pointer is now treated as a possible non-const use. The code only reads through these pointers, so declaring both pointers const together would be valid. Even so, a warning about this one variable alone is a false positive. ---- 19 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/m/metaeuk/metaeuk_7-bba0d80+ds.orig.tar.xz Result: main metaeuk-7-bba0d80/lib/mmseqs/lib/cacode/nrutil.cpp:16:12: style: Variable 'v' can be declared as pointer to const [constVariablePointer] Explanation: `v` is returned as `v - nl` from a function whose return type is `float*`. Declaring `v` as `const float*` would make that return fail to compile without a cast, so the constVariablePointer warning was a false positive. The PR now skips only pointer-minus-pointer subtraction (integer result), so pointer-minus-integer counts as a use that can need a non-const pointer. That removes this false positive, which matches the PR's test case. ---- 20 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/m/metaeuk/metaeuk_7-bba0d80+ds.orig.tar.xz Result: main metaeuk-7-bba0d80/lib/mmseqs/lib/cacode/nrutil.cpp:24:10: style: Variable 'v' can be declared as pointer to const [constVariablePointer] Explanation: In ivector(), 'v' is returned as 'v - nl' from a function whose return type is 'int *'. The result of the subtraction is a pointer, so 'v' cannot be 'const int *' without breaking compilation. The old code treated every '-' parent as a harmless use, which caused this false positive. The PR now ignores '-' only when the result is not a pointer, so the false positive is removed. ---- 21 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/m/metaeuk/metaeuk_7-bba0d80+ds.orig.tar.xz Result: main metaeuk-7-bba0d80/lib/mmseqs/lib/cacode/nrutil.cpp:32:13: style: Variable 'v' can be declared as pointer to const [constVariablePointer] Explanation: `v` is a `double*` and the function returns `v - nl` as a `double*`. The result of that subtraction is a pointer, so declaring `v` as `const double*` would not compile when it is returned as non-const. The old warning was a false positive. The PR now skips '-' only when the result is not a pointer, which removes this false positive. ---- 22 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/m/metaeuk/metaeuk_7-bba0d80+ds.orig.tar.xz Result: main metaeuk-7-bba0d80/lib/mmseqs/src/prefiltering/QueryMatcher.cpp:502:21: style: Variable 'ptr_prev' can be declared as pointer to const [constVariablePointer] Explanation: `ptr_prev - scoreSizes[i]` is pointer arithmetic, and the result is assigned to `ptr[i]`, which has type non-const `CounterResult*`. If `ptr_prev` were declared as pointer to const, that assignment would not compile. The constVariablePointer warning was therefore a false positive. The PR stops treating pointer-result subtraction as a read-only use, which removes it correctly. ---- 23 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/ncl/ncl_6.6.2.dfsg.1.orig.tar.xz Result: main ncl-6.6.2.dfsg.1/ni/src/lib/hlu/MapV40DataHandler.c:1495:9: style: Variable 'cp' can be declared as pointer to const [constVariablePointer] Explanation: The PR stops ignoring pointer arithmetic `cp - n` when the result is still a pointer. It now only skips `-` when the result is a non-pointer, such as a pointer difference. In this function `cp` scans the writable local buffer `buf` through `np`. An expression like `cp - 1` gives a non-const pointer that is then written through or stored. Cppcheck used to ignore that use, which caused the false constVariablePointer warning. The removed warning is consistent with the fix for #15219. The usage lines are not shown, so confidence is medium. ---- 24 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/n/ncl/ncl_6.6.2.dfsg.1.orig.tar.xz Result: main ncl-6.6.2.dfsg.1/ni/src/lib/hlu/MultiText.c:516:8: style: Variable 'cp' can be declared as pointer to const [constVariablePointer] Explanation: `cp` is used in `lcp = cp - 1;`, where `lcp` is a non-const `char*`. If `cp` were declared `const char*`, that assignment would discard the const qualifier, so `lcp` would also have to change. That makes the suggestion to declare only `cp` as pointer to const a false positive. The PR stops treating pointer subtraction that yields a pointer as a read-only use, so this false positive is correctly removed. ---- 25 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/n/ncl/ncl_6.6.2.dfsg.1.orig.tar.xz Result: main ncl-6.6.2.dfsg.1/ni/src/lib/hlu/hlu.c:705:8: style: Variable 'index' can be declared as pointer to const [constVariablePointer] Explanation: `index` is only read through: `*index != '\0'`, `index++` and `*(index - 1) == 'F'`. Nothing is written through it, so `const char *index` would work and the warning was a true positive. The PR no longer skips a pointer-typed `-` parent such as `index - 1`. Because of that, this read-only use is now treated as possibly non-const, and the valid warning is lost. This is a new false negative. ---- 26 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/ncl/ncl_6.6.2.dfsg.1.orig.tar.xz Result: main ncl-6.6.2.dfsg.1/ni/src/ncl/NclGRIB.c:6299:4: style: Variable 'endcp' can be declared as pointer to const [constVariablePointer] Explanation: Line 6299 expands the TOKENEND macro, which defines a local `endcp` and then does something like `lcp = endcp - 1`. Pointer minus integer gives a pointer to the same non-const type, and here it is stored in `char *lcp`. Declaring `endcp` as pointer to const would break that assignment, so the old constVariablePointer warning was a false positive. The PR now only skips `-` when the result is not a pointer, which is exactly the #15219 case. Removing this warning is correct. Confidence is medium because the macro body is not shown in the excerpt. ---- 27 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/ncl/ncl_6.6.2.dfsg.1.orig.tar.xz Result: main ncl-6.6.2.dfsg.1/ni/src/ncl/NclGRIB.c:6323:4: style: Variable 'endcp' can be declared as pointer to const [constVariablePointer] Explanation: The TOKENEND macro is not shown, but it most likely declares a local `char *endcp` and assigns `endcp - 1` back to the non-const `char *lcp`. If `endcp` were made pointer to const, that assignment would no longer compile without a cast, so the old warning was a false positive. This is exactly the case the PR fixes: when `-` produces a pointer result, it is no longer treated as a read-only use. Removing the warning is therefore an improvement. ---- 28 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/ncl/ncl_6.6.2.dfsg.1.orig.tar.xz Result: main ncl-6.6.2.dfsg.1/ni/src/ncl/NclGRIB.c:6395:10: style: Variable 'e' can be declared as pointer to const [constVariablePointer] Explanation: `e` is only assigned from `strstr()` and used in the pointer differences `e-ent->d_name`. It is never written through, so `const char *e` would be valid and the warning was a true positive. The PR now skips `-` only when the subtraction has a known non-pointer valueType. Here that type is probably unknown, because `struct dirent`/`d_name` type info is likely missing. So the subtraction is no longer skipped and the true positive is lost: a new false negative. ---- 29 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/nss-pem/nss-pem_1.1.1+1.orig.tar.xz Result: main nss-pem-1.1.1+1/src/pfind.c:302:5: style: Variable '__mptr' can be declared as pointer to const [constVariablePointer] Explanation: `__mptr` almost certainly comes from a `container_of`-style macro: `typeof(...) *__mptr = (ptr); (type *)((char *)__mptr - offsetof(...))`. Here `__mptr` is used in pointer arithmetic, and the result becomes a non-const `type *` returned to the caller. Before the PR, any parent `-` was skipped, so this use was ignored. The PR now ignores `-` only when the result is not a pointer, which matches the new test case (`int* q = s - 1`). Flagging a macro-internal variable whose pointee is handed out as non-const is a false positive, so removing it is an improvement. The source file was not available, so the macro text is inferred from the variable name. ---- 30 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/nss-pem/nss-pem_1.1.1+1.orig.tar.xz Result: main nss-pem-1.1.1+1/src/pinst.c:367:5: style: Variable '__mptr' can be declared as pointer to const [constVariablePointer] Explanation: `__mptr` is the temporary inside a `container_of`-style macro: `(type *)((char *)__mptr - offsetof(type, member))`. Pointer arithmetic on `__mptr` produces a new non-const pointer, and the macro hands that pointer back for writing. The PR stops treating a pointer-valued `-` as harmless, which is exactly this pattern, and it is the case of #15219. Making `__mptr` const would only work because the later cast silently strips const, so the suggestion has little value. The warning also fires in every macro expansion, so it is noise. Its removal is consistent with the intended fix, so this is a removed false positive. ---- 31 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/nss-pem/nss-pem_1.1.1+1.orig.tar.xz Result: main nss-pem-1.1.1+1/src/pinst.c:387:5: style: Variable '__mptr' can be declared as pointer to const [constVariablePointer] Explanation: `__mptr` comes from a `container_of`-style macro: `typeof(...) *__mptr = (ptr); (type *)((char *)__mptr - offsetof(...))`. The pointer arithmetic result is returned as a non-const `type*`. Making `__mptr` const would only compile by casting away const, so the suggestion is a false positive. It is also reported inside a macro expansion the user cannot easily change. The PR stops ignoring `-` when the result is a pointer, which matches the added test case (`int* q = s - 1; return q;`). Removing this warning is correct. ---- 32 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/nss-pem/nss-pem_1.1.1+1.orig.tar.xz Result: main nss-pem-1.1.1+1/src/pinst.c:414:5: style: Variable '__mptr' can be declared as pointer to const [constVariablePointer] Explanation: `__mptr` comes from a container_of-style macro. Since main warned, the macro must declare `__mptr` non-const (e.g. `void *__mptr = (void *)(ptr); (type *)(__mptr - offsetof(...))`). The result of `__mptr - offset` is a pointer that is then cast to a non-const `type*`. Making `__mptr` const would mean casting away const, so the warning was a false positive. It was also in macro code the user can't easily change. The PR now stops treating pointer-valued subtraction as a read-only use, which removes this false positive. ---- 33 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/nss-pem/nss-pem_1.1.1+1.orig.tar.xz Result: main nss-pem-1.1.1+1/src/pobject.c:1201:9: style: Variable '__mptr' can be declared as pointer to const [constVariablePointer] Explanation: `__mptr` almost certainly comes from a Linux-style `container_of` macro: `typeof(...) *__mptr = (ptr); (type *)((char *)__mptr - offsetof(...))`. The pointer arithmetic produces a non-const pointer that the caller uses to modify the containing object. Declaring `__mptr` const would only compile because the C cast silently drops the const, so the old warning was effectively a false positive. It was also noise, since it pointed at a variable inside a macro. The PR now skips only non-pointer `-` results and keeps checking pointer arithmetic that yields a usable pointer, so removing this warning fits its intent. The source file was not available to confirm the macro. ---- 34 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/nss-pem/nss-pem_1.1.1+1.orig.tar.xz Result: main nss-pem-1.1.1+1/src/psession.c:259:5: style: Variable '__mptr' can be declared as pointer to const [constVariablePointer] Explanation: `__mptr` is the temporary inside a `container_of`-style macro, roughly `(type *)((char *)__mptr - offsetof(type, member))`. The source file was not available, so this reading is inferred from the variable name. The pointer subtraction produces a non-const pointer to the enclosing struct, which callers then use to modify it. Before the PR, any `-` parent was skipped as a read-only use. The PR now treats pointer-valued subtraction as a possible non-const use, matching its test case (`int* q = s - 1;`). Declaring `__mptr` const would only compile here because the C cast silently drops const, so the warning was at best noise. It also sits on a macro-internal variable that users cannot easily change. Removing it is consistent with the PR's intent, so this is a removed false positive. ---- 35 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/o/openafs/openafs_1.8.17~pre2.orig.tar.xz Result: main openafs_1.8.17~pre2.orig/src/afs/HPUX/osi_groups.c:107:10: style: Variable 'gp' can be declared as pointer to const [constVariablePointer] Explanation: In afs_getgroups, 'gp' is only used for reading: it is compared, read through gp[-1] and *gp++, and used in the pointer difference 'gp - cred->cr_groups'. It is never written through, so 'const int *gp' would be valid and the old warning was a true positive. The PR now skips the '-' parent only when the result has a known non-pointer value type. Here the type of 'cred->cr_groups' is probably unknown because struct ucred is not defined, so the subtraction no longer counts as a const use. That makes this a new false negative. ---- 36 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/o/openafs/openafs_1.8.17~pre2.orig.tar.xz Result: main openafs_1.8.17~pre2.orig/src/sys/pioctl_nt.c:653:11: style: Variable 'drivep' can be declared as pointer to const [constVariablePointer] Explanation: In openafs's GetIoctlHandle, 'drivep' is set from strchr(fileNamep, ':'). It is then only read, through expressions like '(drivep - fileNamep)' and '*(drivep - 1)'. Nothing is written through it, so it could be 'const char *' and the old warning was a true positive. The PR no longer skips a '-' whose result is a pointer. So 'drivep - 1' is now treated as a possible non-const use, and the warning disappears. That is a new false negative. The exact uses are inferred from upstream openafs, because the snippet does not show them. ---- 37 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/o/openafs/openafs_1.8.17~pre2.orig.tar.xz Result: main openafs_1.8.17~pre2.orig/src/uss/uss_procs.c:659:38: style: Parameter 'cp' can be declared as pointer to const [constParameterPointer] Explanation: In the visible code `cp` is only read through `*(cp - 1)` and compared with `path` and `&path[i]`. Nothing writes through it, so it could be `const char *` and the warning looks like a true positive. The PR stops skipping `-` when the result is a pointer, as in `cp - 1`. That makes the check give up, so this valid warning disappears: a new false negative. Confidence is medium because the rest of the function is not shown. ---- 38 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/o/openblas/openblas_0.3.34+ds.orig.tar.xz Result: main OpenMathLib-OpenBLAS-e016600/driver/level2/trsv_U.c:71:14: style: Variable 'AA' can be declared as pointer to const [constVariablePointer] Explanation: `AA` is a non-const pointer. In the non-TRANSA build, `AA - (min_i - i - 1)` is passed to `AXPYU_K`. OpenBLAS axpy kernels take a non-const `FLOAT *x`, so declaring `AA` as pointer to const would not compile cleanly. Before the PR, the `-` parent was always skipped, so this pointer arithmetic was ignored and the check wrongly suggested const. Now pointer-typed subtraction results are tracked, and the false positive is gone. ---- 39 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/o/openblas/openblas_0.3.34+ds.orig.tar.xz Result: main OpenMathLib-OpenBLAS-e016600/kernel/mips/dtrsm_kernel_RT_8x4_msa.c:876:48: style: Parameter 'b' can be declared as pointer to const [constParameterPointer] Explanation: In dsolve_1x1_rt_msa, 'b' is only read: through b[i] and through *(b - 1). It is never written, so declaring it 'const FLOAT *b' is valid and the warning was a true positive. The PR now treats any pointer-valued '-' expression as a possible non-const use. That fixes cases like 'int* q = s - 1; return q;', but it also drops this read-only dereference of 'b - 1'. The result is a new false negative. ---- 40 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/o/openblas/openblas_0.3.34+ds.orig.tar.xz Result: main OpenMathLib-OpenBLAS-e016600/kernel/mips/strsm_kernel_LN_8x8_msa.c:1596:38: style: Parameter 'a' can be declared as pointer to const [constParameterPointer] Explanation: In ssolve_1x1_ln_msa, 'a' is only read, through a[k] and *(a - 1), and is never written through. So the constParameterPointer warning in main was a true positive. The PR stops skipping pointer subtraction when the result is a pointer, so 'a - 1' is now treated as a possible non-const use. That suppresses this valid warning, which is a new false negative and a side effect of fixing the FP in #15219. ---- 41 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/o/openblas/openblas_0.3.34+ds.orig.tar.xz Result: main OpenMathLib-OpenBLAS-e016600/kernel/mips/strsm_kernel_RT_8x8_msa.c:1583:38: style: Parameter 'a' can be declared as pointer to const [constParameterPointer] Explanation: In ssolve_1x1_rt_msa, 'a' is only read: through a[k] and *(a - 1). It is never written, so it could be declared as pointer to const, and the removed warning was a true positive. The PR now skips every pointer subtraction ('a - 1' has pointer type), which is needed for cases like returning 's - 1' as non-const. Here the result is only dereferenced for reading, so this is a new false negative. ---- 42 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/p/poke/poke_5.0+dfsg.orig.tar.xz Result: main poke-5.0/jitter/example-vms/jitterlisp/jitterlisp-error.c:114:9: style: Variable 'first_unused_char' can be declared as pointer to const [constVariablePointer] Explanation: `first_unused_char - sizeof(...)` is pointer arithmetic, and the result is cast to a non-const `struct jitterlisp_error_context *` and returned. If `first_unused_char` were declared `const char *`, that cast would discard const. So the old constVariablePointer warning was a false positive. The PR now only skips binary '-' when the result is not a pointer, so pointer subtraction that yields a pointer no longer triggers the warning. ---- 43 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/r/renderdoc/renderdoc_1.24+dfsg.orig.tar.xz Result: main renderdoc-1.24/renderdoc/3rdparty/zstd/huf_decompress.c:164:71: style: Parameter 'pEnd' can be declared as pointer to const [constParameterPointer] Explanation: In HUF_decodeStreamX1, 'pEnd' is only read: it appears in comparisons (`p < pEnd-3`, `p < pEnd`) and in the difference `pEnd-pStart`. Nothing is ever written through it, so declaring it `const BYTE* const pEnd` would compile fine, since comparing BYTE* with const BYTE* is valid. The removed warning was therefore a true positive. The PR no longer skips a '-' whose result is a pointer (`pEnd-3`), so this valid warning is now missed. That is a new false negative, accepted as the cost of fixing #15219. ---- 44 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/r/renderdoc/renderdoc_1.24+dfsg.orig.tar.xz Result: main renderdoc-1.24/renderdoc/3rdparty/zstd/zstd_decompress.c:1043:43: style: Parameter 'oend' can be declared as pointer to const [constParameterPointer] Explanation: `oend - WILDCOPY_OVERLENGTH` yields a non-const `BYTE*`, which is stored in `BYTE* const oend_w`. `oend_w` is then passed to `ZSTD_wildcopy` and assigned to `op`, which is written through (`*op++ = ...`). If `oend` were declared `const BYTE*`, the line `BYTE* const oend_w = oend - ...` would not compile. The constParameterPointer warning was a false positive. The PR now treats pointer arithmetic that yields a pointer as a non-const use, which removes it. ---- 45 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/s/squid/squid_7.8.orig.tar.xz Result: main squid-7.8/lib/radix.c:416:25: style: Variable 'cplim' can be declared as pointer to const [constVariablePointer] Explanation: In this BSD-derived `squid_rn_addmask`, `cplim` is only set (`cplim = netmask + mlen`) and then read in comparisons such as `cp < cplim` and `cp != (cplim - 1)`. Nothing is ever written through it, so declaring it `const char *` would compile fine, and the old warning was a true positive. The PR now skips the const check when `-` produces a pointer result, so `cplim - 1` makes Cppcheck treat `cplim` as possibly non-const, even though that result is only compared. This loses a true positive, i.e. a new false negative. Confidence is medium because the lines that use `cplim` fall outside the shown excerpt; their content is taken from the original BSD radix.c. ---- 46 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/s/squid/squid_7.8.orig.tar.xz Result: main squid-7.8/src/sbuf/SBuf.cc:734:11: style: Variable 'cur' can be declared as pointer to const [constVariablePointer] Explanation: In this code, 'cur' is only read through (`set[*cur]`), compared (`cur < bufend`), incremented, and used in the pointer difference `cur-buf()`. None of these need a non-const pointee, so 'cur' could indeed be declared `const char *cur`, and the warning was a true positive. The PR now only skips '-' when its valueType is known to be non-pointer. Here the type of `cur-buf()` is likely not resolved, so the check stops treating this use as harmless and the valid warning is lost. That is a new false negative. ---- 47 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/s/squid/squid_7.8.orig.tar.xz Result: main squid-7.8/src/sbuf/SBuf.cc:757:11: style: Variable 'cur' can be declared as pointer to const [constVariablePointer] Explanation: `cur` is only compared, dereferenced for reading, incremented, and used in `cur-buf()` to compute a difference. Nothing is written through it, so it could be `const char*` and the warning was a true positive. The PR now skips `-` only when the result's valueType is known to be a non-pointer. Here the valueType of `cur-buf()` is apparently not determined, so the usage is treated as possibly non-const and the valid warning is lost. This is a new false negative. ---- 48 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/t/tor/tor_0.4.9.16.orig.tar.gz Result: main tor-0.4.9.16/src/lib/buf/buffers.c:755:11: style: Variable 'cp' can be declared as pointer to const [constVariablePointer] Explanation: `cp` is only used in a null check and in the pointer differences `cp - chunk->data`. It is never written through, so `const char *cp` would be valid and the warning was a true positive. The PR now skips '-' only when the parent has a known non-pointer valueType. In this C code the pointer-difference expression apparently has no valueType, so the usage is now treated as non-const and the true positive is lost (a new false negative). ---- 49 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/t/tor/tor_0.4.9.16.orig.tar.gz Result: main tor-0.4.9.16/src/lib/buf/buffers.c:857:11: style: Variable 'cp' can be declared as pointer to const [constVariablePointer] Explanation: `cp` gets the result of `memchr` and is only null-checked and used in the pointer difference `cp - chunk->data`. Neither use writes through it, so `const char *cp` would be valid and the warning was a true positive. The PR now skips `-` only when the subtraction's value type is known to be a non-pointer. Here the type of the `-` expression is apparently not determined, so the check no longer skips it and the warning is lost. This is a new false negative, not a removed false positive. ---- 50 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/v/valkey/valkey_9.1.3.orig.tar.gz Result: main valkey-io-valkey-29173b6/deps/libvalkey/src/read.c:245:15: style: Variable 's' can be declared as pointer to const [constVariablePointer] Explanation: In readLine, `s` is assigned from `seekNewline()`, compared with NULL, and used in the pointer difference `s - (r->buf + r->pos)`. It is never written through or passed on as non-const, so `const char *s` would be valid and the original warning was a true positive. The PR now only skips `-` when the subtraction's valueType is known to be non-pointer. For this pointer difference the valueType is apparently missing or seen as a pointer, so the check no longer fires and a true positive is lost.