Question
SonarQube requesting explicit cast on the result of the shift operator
I have a ton of similar issues reported by SonarQube:
m_buffer[0] = static_cast<uint32_t>(headerByte0 << 8);
Where m_buffer
is an array of uint32_t
, headerByte0
is uint8_t
. SonarQube writes:
Add an explicit cast to the result of the "<<" operator.
There is a reference to MISRA C 2004 10.5 and MISRA C++ 2008 5-0-10. Why does SonarQube not recognize the static_cast
? How to solve this?