Cppcheck's suggestion to make ptr const in the below code seems problematic given that the return type is non-const and compilers find such a change rather unamusing. (godbolt)
file.cpp:21:16: style: Variable 'ptr' can be declared as pointer to const [constVariable]
for (auto* ptr : ptrs)
Below is a copy of the working version of the godbolt (cppcheck --enable=all --std=c++20 --platform=win64 .\file.cpp):
Cppcheck's suggestion to make
ptr
const in the below code seems problematic given that the return type is non-const and compilers find such a change rather unamusing. (godbolt)file.cpp:21:16: style: Variable 'ptr' can be declared as pointer to const [constVariable] for (auto* ptr : ptrs)
Below is a copy of the working version of the godbolt (
cppcheck --enable=all --std=c++20 --platform=win64 .\file.cpp
):No repro with head, so it seems to have been fixed already.