[LLVMbugs] [Bug 11013] New: clang --analyze segmentation fault on simple valid C for() loop

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Sep 26 09:18:24 PDT 2011


           Summary: clang --analyze segmentation fault on simple valid C
                    for() loop
           Product: clang
           Version: 2.9
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: adam.spragg at octaltelecom.co.uk
                CC: llvmbugs at cs.uiuc.edu

If I run clang --analyze on the following code, which, as far as I can tell is
valid (it compiles fine with clang and GCC) then I get the following:

$ clang --version
clang version 2.9 (tags/RELEASE_29/final)
Target: i386-pc-linux-gnu
Thread model: posix
$ clang --analyze clang-break.c 
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal 1 (use -v to see

#include <stdio.h>
#include <stdlib.h>

struct bits {
    long bit_id;
    long collection_id;
    char member1[256];

void bits_select(struct bits ** pdest, size_t * plen, void * db, long id);

void show_bits_from_collection(void * db, long collection_id)
  struct bits * thebits = NULL;
  size_t nbits = 0;
  unsigned i;

  bits_select(&thebits, &nbits, db, collection_id);

  for (i = 0; i <= nbits; ++i) {
    struct bits newbit = { -1, collection_id, "" };
    struct bits * pbit = (i < nbits) ? &thebits[i] : &newbit;

    printf("Bit id: %ld\n", pbit->bit_id);



This is clang 2.9 from Debian testing. It analyzed without segfaulting under

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list