I was recently testing Wine with the Clang static analyzer, which
found a few issues in wine's configure.ac:
http://source.winehq.org/git/wine.git/commitdiff/8521ebe79df39730ee62d518fde3751f45606061

there are a few more warnings, however, that come from autoconf itself:
austin@aw25 ~/wine-git $
~/src/llvm/tools/clang/tools/scan-build/scan-build clang foo.c
scan-build: 'clang' executable not found in
'/home/austin/src/llvm/tools/clang/tools/scan-build/bin'.
scan-build: Using 'clang' from path: /usr/local/bin/clang
foo.c:31:5: warning: Dereference of undefined pointer value
    *t++ = 0;
    ^
foo.c:22:22: warning: Both operands to '-' always have the same value
  pcpcc = &g + (g ? g-g : 0);
                    ~^~
foo.c:22:14: warning: The right operand to '+' is always 0
  pcpcc = &g + (g ? g-g : 0);
             ^ ~~~~~~~~~~~~~
foo.c:26:3: warning: Value stored to 'pcpcc' is never read
  pcpcc = (char const *const *) ppc;
  ^       ~~~~~~~~~~~~~~~~~~~~~~~~~
4 warnings generated.
scan-build: 4 bugs found.
scan-build: Run 'scan-view /tmp/scan-build-2011-06-14-3' to examine bug reports.

foo.c is attached, which is just that configure test in a standalone c file.

-- 
-Austin
#include <stdio.h>

int
main ()
{
/* FIXME: Include the comments suggested by Paul. */
#ifndef __cplusplus
  /* Ultrix mips cc rejects this.  */
  typedef int charset[2];
  const charset cs;
  /* SunOS 4.1.1 cc rejects this.  */
  char const *const *pcpcc;
  char **ppc;
  /* NEC SVR4.0.2 mips cc rejects this.  */
  struct point {int x, y;};
  static struct point const zero = {0,0};
  /* AIX XL C 1.02.0.0 rejects this.
     It does not let you subtract one const X* pointer from another in
     an arm of an if-expression whose if-part is not a constant
     expression */
  const char *g = "string";
  pcpcc = &g + (g ? g-g : 0);
  /* HPUX 7.0 cc rejects these. */
  ++pcpcc;
  ppc = (char**) pcpcc;
  pcpcc = (char const *const *) ppc;
  { /* SCO 3.2v4 cc rejects this.  */
    char *t;
    char const *s = 0 ? (char *) 0 : (char const *) 0;

    *t++ = 0;
    if (s) return 0;
  }
  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
    int x[] = {25, 17};
    const int *foo = &x[0];
    ++foo;
  }
  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
    typedef const int *iptr;
    iptr p = 0;
    ++p;
  }
  { /* AIX XL C 1.02.0.0 rejects this saying
       "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
    struct s { int j; const int *ap[3]; };
    struct s *b; b->j = 5;
  }
  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
    const int foo = 10;
    if (!foo) return 0;
  }
  return !cs[0] && !zero.x;
#endif

  ;
  return 0;
}

Reply via email to