Menu

negativeShift error when stream operator used.

2018-04-18
2018-04-18
  • Stefan Pantos

    Stefan Pantos - 2018-04-18

    In our project we have a macro something like this:

    #define TRACE(level, output) do { if (level <= traceLevel) cerr << output << endl;}while(false);

    when this macro is called like this:

    void f(int x)
    {
        TRACE(low, "Some string" << x);
    }
    

    We get the error negativeShift.

    Similarly happens with BOOST_MESSAGE from the boost unit library.

    Is there a suggested way to avoid this?

    Thankyou.

     
  • versat

    versat - 2018-04-18

    Thanks for your report.
    I have tried to reproduce it with Cppcheck V1.83 and the latest development version but i do not get any negativeShift or other wrong message. I tried it without Cppcheck knowing the macro and with the define, but in both cases i do not get a negativeShift message.
    What version of Cppcheck do you use?
    Do you still get the message for the reduced example or only in a project?
    If it happens with the latest version and the reduced example maybe the parameters you provide to Cppcheck matter, can you give details about that?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.