You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Analyzer suggest adding 'const' qualifier for mutable std::bitset instance that changes in the for-loop.
Example
foo.h
#include<bitset>structA {
staticconstint length = 128;
staticvoidbar(std::bitset<length> & a, const std::bitset<length> & b, int a_start = 0, int b_start = 0);
}
foo.cpp
voidA::bar(std::bitset<length> & a, const std::bitset<length> & b, int a_start, int b_start)
{
for (int i = a_start, j = b_start; i < A::length && j < A::length; ++i, ++j) {
int sum = static_cast<int>(a[i]) + static_cast<int>(b[j]);
a[i] = static_cast<bool>(sum % 2);
}
}
Compiler message
[ 5%] Building CXX object CMakeFiles/expressions_lib.dir/src/foo.cpp.o
error: 'a' can have 'const' qualifier [const-param]
void A::bar(std::bitset<length> & a, const std::bitset<length> & b, int a_start, int b_start)
^
1 error generated.
Build info
Clang 11.0.0
The text was updated successfully, but these errors were encountered:
Description
Analyzer suggest adding 'const' qualifier for mutable std::bitset instance that changes in the for-loop.
Example
Compiler message
Build info
Clang 11.0.0
The text was updated successfully, but these errors were encountered: