Click here to Skip to main content
15,892,674 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Coverity Scan for Visual Studio / C++ Pin
Stuart Dootson13-May-20 2:30
professionalStuart Dootson13-May-20 2:30 
GeneralRe: Coverity Scan for Visual Studio / C++ Pin
Greg Utas13-May-20 2:12
professionalGreg Utas13-May-20 2:12 
GeneralRe: Coverity Scan for Visual Studio / C++ Pin
Stuart Dootson13-May-20 2:38
professionalStuart Dootson13-May-20 2:38 
GeneralRe: Coverity Scan for Visual Studio / C++ Pin
Greg Utas13-May-20 2:54
professionalGreg Utas13-May-20 2:54 
GeneralRe: Coverity Scan for Visual Studio / C++ Pin
Greg Utas13-May-20 3:09
professionalGreg Utas13-May-20 3:09 
GeneralRe: Coverity Scan for Visual Studio / C++ Pin
Stuart Dootson13-May-20 3:22
professionalStuart Dootson13-May-20 3:22 
GeneralRe: Coverity Scan for Visual Studio / C++ Pin
kalberts13-May-20 3:51
kalberts13-May-20 3:51 
GeneralRe: Coverity Scan for Visual Studio / C++ Pin
Stuart Dootson13-May-20 4:47
professionalStuart Dootson13-May-20 4:47 
Thing is that the error I saw implied that Coverity wasn't correctly analysing the code in the C++ runtime - when a function is called with a parameter supplied with a statically constant argument value (defined using C++'s constexpr keyword, which is equivalent to a numeric literal), the flow analysis should be able to detect that the conditional code (which would have raised the exception) is not going to be executed, so the exception cannot be raised. That is not something that would be solved by suppressing some of the checks.

The tracebacks were very helpful - that part was absolutely what I'd want to see! In the end, though, the error came down to this function:
C++
    void __CLR_OR_THIS_CALL clear(iostate _State, bool _Reraise)
            {       // set state, possibly reraise exception
            _State &= _Statmask;
            _Mystate = _State;
            const auto _Filtered = _State & _Except;
            if (_Filtered)
                    {
                    if (_Reraise)
                            {
                            _RERAISE;
                            }

                    const char * _Msg;
                    if (_Filtered & ios_base::badbit)
                            {
                            _Msg = "ios_base::badbit set";
                            }
                    else if (_Filtered & ios_base::failbit)
                            {
                            _Msg = "ios_base::failbit set";
                            }
                    else
                            {
                            _Msg = "ios_base::eofbit set";
                            }
1. exception_thrown: An exception of type std::ios_base::failure is thrown.
                    _THROW(failure(_Msg));
                    }
            }

Trouble is that _State was passed as std::ios_base::goodbit, which the C++ standard defines as being zero (and it's defined as such in therelevant header). This mans that the local variable _Filtered must be zero (as zero bitwise-and anything equals zero), so the if (_Filtered) if block will never be executed.

I do have a history of stumbling over bugs in static analysis tools, mind - I found one in PRQA-C when using it at work to analyse an embedded software project. That bug caused PRQA to think that arrays were one element smaller than they'd been declared (i.e. PRQA would think that bool array[10]; had 9 elements, not 10...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

GeneralRe: Coverity Scan for Visual Studio / C++ Pin
kalberts13-May-20 5:25
kalberts13-May-20 5:25 
GeneralRe: Coverity Scan for Visual Studio / C++ Pin
User 4041113-May-20 20:41
User 4041113-May-20 20:41 
GeneralRe: Coverity Scan for Visual Studio / C++ Pin
Greg Utas14-May-20 0:17
professionalGreg Utas14-May-20 0:17 
GeneralMessage Closed Pin
14-May-20 0:25
User 4041114-May-20 0:25 
GeneralRe: Coverity Scan for Visual Studio / C++ Pin
Greg Utas14-May-20 0:33
professionalGreg Utas14-May-20 0:33 
GeneralSo I am a little depressed by my COVID lockdown weight gain... PinPopular
DRHuff12-May-20 5:47
DRHuff12-May-20 5:47 
GeneralRe: So I am a little depressed by my COVID lockdown weight gain... Pin
den2k8812-May-20 5:51
professionalden2k8812-May-20 5:51 
GeneralRe: So I am a little depressed by my COVID lockdown weight gain... Pin
Mike Hankey12-May-20 6:13
mveMike Hankey12-May-20 6:13 
GeneralRe: So I am a little depressed by my COVID lockdown weight gain... Pin
lopatir12-May-20 7:08
lopatir12-May-20 7:08 
GeneralRe: So I am a little depressed by my COVID lockdown weight gain... Pin
Mike Hankey12-May-20 7:19
mveMike Hankey12-May-20 7:19 
GeneralRe: So I am a little depressed by my COVID lockdown weight gain... Pin
lopatir12-May-20 7:24
lopatir12-May-20 7:24 
GeneralRe: So I am a little depressed by my COVID lockdown weight gain... Pin
Mike Hankey12-May-20 7:59
mveMike Hankey12-May-20 7:59 
GeneralRe: So I am a little depressed by my COVID lockdown weight gain... Pin
Slacker00712-May-20 6:32
professionalSlacker00712-May-20 6:32 
JokeRe: So I am a little depressed by my COVID lockdown weight gain... Pin
PIEBALDconsult12-May-20 12:27
mvePIEBALDconsult12-May-20 12:27 
GeneralThought of the Day Pin
OriginalGriff12-May-20 4:46
mveOriginalGriff12-May-20 4:46 
GeneralRe: Thought of the Day Pin
Tim Deveaux12-May-20 4:49
Tim Deveaux12-May-20 4:49 
GeneralRe: Thought of the Day Pin
Mike Hankey12-May-20 4:49
mveMike Hankey12-May-20 4:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.