http://llvm.org/bugs/show_bug.cgi?id=11013

           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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


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
invocation)
$ 

---8<---clang-break.c---8<---
#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);
  }

  free(thebits);
  return;
}

---8<---clang-break.c---8<---

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

-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to