On Wed, 25 Mar 2020 at 22:38, Andrew Briand wrote:
>
> Hello,
>
> I am an undergrad interested in extending GCC’s static analysis pass for GSoC 
> 2020. In particular, I’m interested in adding C++ support.
>
> The selected project ideas list mentions adding new/delete checking and 
> exception checking. The features that immediately come to my mind would be 
> checking for undeleted allocations, mixing delete and delete[], double 
> deletion (it seems the current static analyzer already checks for double 
> free), and uncaught exceptions.

I'm not sure reporting about uncaught exceptions is useful, except in
the (unlikely) case where the entire program is visible to the
compiler, or maybe as an extension of the -Wterminate warning.
Exceptions are *supposed* to be uncaught in most code, so they
propagate to a layer that can actually do something about the error.

Some other ideas for C++ code could be:

- Locking a mutex twice, or locking it and not unlocking it in the same scope.

- Locking and unlocking a mutex around a region with no side effects
(i.e. no I/O, no volatile read/writes, no atomic operations on
non-local variables).

- Using a shared_ptr where there's only a single owner so unique_ptr would work.

- Returning a reference/pointer to a local variable through another
function (which the current -Wreturn-local-addr warning can't
diagnose) e.g.
int& f(int& i) { return i; }
int& g() { int i = 0; return f(i); }

Reply via email to