[cfe-dev] improving detection of uninitialized arguments (the CallAndMessageChecker)

Dmitri Gribenko gribozavr at gmail.com
Fri Feb 14 07:21:33 PST 2014


On Fri, Feb 14, 2014 at 12:41 PM, Per Viberg <Per.Viberg at evidente.se> wrote:
>
> Hi,
>
> I'm looking into extending the check that warns for uninitialized arguments.
> Below I've described what should be detected. Any opinions on if it's a
> useful check or potential problems/drawbacks with it?.
>
> Check: should this be detected as a warning for uninitialized
> argument?:"warning: Function call argument is an uninitialized value"
>
> void doStuff(const int *p);
> void f(void);
>
> void f(void) {
>       int x;
>       doStuff(&x);  // ← warning?
> }

doStuff() is allowed to const_cast the constness away and modify 'x'.

But even if we allow a false positive in that case, we should also
make sure that the address of 'x' does not escape before the call.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/




More information about the cfe-dev mailing list