Hammer on snapshot cd's

Matthew Dillon dillon at apollo.backplane.com
Tue Jul 15 14:46:49 PDT 2008


   One interesting thing I've found on GCC-4 is that the callgraph analyzer
   will cross procedure boundaries for all procedures in that particular
   source file.  It can actually detect that error is left uninitialized
   in this situation:

    cc -Wall x.c -c -O2
    x.c: In function 'fubar2':
    x.c:16: warning: 'error' is used uninitialized in this function

    (edit so *valuep is set to 0)

    cc -Wall x.c -c -O2
    (no warning reported)

#include <stdio.h>

void
fubar1(int *valuep)
{
    /* *valuep = 0; */
}

void
fubar2(void)
{
    int error;

    fubar1(&error);
    printf("error = %d\n", error);
}

    GCC-4 actually caught a bug during HAMMER development from that sort
    of thing.  I was impressed.

					-Matt
					Matthew Dillon 
					<dillon at backplane.com>





More information about the Users mailing list