itiviti-cpp-analyzer icon indicating copy to clipboard operation
itiviti-cpp-analyzer copied to clipboard

False warning: 'm_significand' can be constructed in initializer list

Open olegoratovskiy opened this issue 3 years ago • 0 comments

Description

Analyzer suggests constructing m_significand in the initializer list

Example

// int64_t m_significand & int64_t m_exponent are private fields of struct Exponential

Exponential::Exponential(int64_t number)
    : m_significand(number)
    , m_exponent(0)
{
    while (m_significand != 0 && m_significand % 10 == 0) {
        ++m_exponent;
        m_significand /= 10;
    }
}

Compile message

[  6%] Building CXX object CMakeFiles/expressions_lib.dir/src/exponential.cpp.o
error: 'm_significand' can be constructed in initializer list
m_significand /= 10;
        ^

olegoratovskiy avatar May 21 '22 23:05 olegoratovskiy