V Mon, 18 Dec 2017 11:57:49 +0100
Stefan Hundhammer <[email protected]> napsáno:
> On 13.12.2017 10:35, Josef Reidinger wrote:
> > How does coverity or other handle pointers in C++? I think it is
> > similar kind of issue as ruby have for static analysis. Any pointer
> > can be NULL or invalid address and similar in ruby anything can be
> > nil.
>
> Coverity will (among a lot of other things) complain if you use a
> pointer that you got e.g. as a function parameter and didn't check it
> first before dereferencing it. Sometimes this will result in false
> positives, but an extra check is cheap and can indeed prevent a
> segfault.
>
>
> Kind regards
If I get it correctly coverity report when pointer is assigned from
unknown source ( e.g. that function parameter or its result ) and not
checked? So it basically would like to see stuff
a = method();
if (a)
b = *a;
or
void m(char *c)
{
if !c
return;
...
}
I think check like this can be done also for ruby, but I am not sure
how much it will affect current code, because some methods can live
with nil and some method require to not get it ( e.g. some private
methods ). So I expect huge amount of false positives.
Josef
--
To unsubscribe, e-mail: [email protected]
To contact the owner, e-mail: [email protected]