Debugger
Debugger

Reputation: 17

Getting Klocwork Error while using std::hex and std::dec

Recently while using std::hex and std::dec I am getting below Klocwork Error in below code.

#include <bits/stdc++.h>
#include <stdint.h>

void func(std::stringstream& s)
{
    std::string name="str";
    int val[2]={'0', '1'};

    s << "\n" << name << ": " << std::hex << "\t";

    for (int i = 0; i < sizeof(val); i++)
    {
        s << val[i] << " ";
    }

    s << "\n" << std::dec;

    std::cout << s.str();
}

int main()
{
    std::stringstream s;
    func(s);
}

Can anyone help in this how I can resolve this issue.

Klocwork Errors

CWARN.FUNCADDR (2:Error) Analyze
Address of function 'hex' is used instead of a call to this function

CWARN.FUNCADDR (2:Error) Analyze
Address of function 'dec' is used instead of a call to this function

Upvotes: 0

Views: 41

Answers (0)

Related Questions