[cfe-commits] r62812 - in /cfe/trunk: include/clang/AST/Expr.h lib/Sema/Sema.h lib/Sema/SemaInit.cpp test/Sema/designated-initializers.c

sanjiv gupta sanjiv.gupta at microchip.com
Thu Jan 22 21:58:19 PST 2009


clang asserts for a simple array initialization test case for PIC16.

$ clang -arch=pic16 -emit-llvm-bc char_array.c

clang: /home/cvsuser/Projects/c16/include/llvm/ADT/APInt.h:793: bool
llvm::APInt::operator==(const llvm::APInt&) const: Assertion `BitWidth
== RHS.BitWidth && "Comparison requires equal bit widths"' failed.

The test case is below.

char *ptr = (char *)0xA0;
char a;
char arr[10] = {0,1,2,3,4,5,6,7,8,9};

void main()
{
 a = arr[1];
 *ptr = a;
}




> +      // If the array is of incomplete type, keep track of the number of
> +      // elements in the initializer.
> +      if (!maxElementsKnown && elementIndex > maxElements)
> +        maxElements = elementIndex;
>  
Asserts here since elementIndex is of Type APSInt (Bit Width = 32) and
the statement somewhere above this code  

   maxElements = CAT->getSize();

changes maxElements to APInt (BitWidth = 16). CAT->getSize() return
APInt of BitWidth=16.






More information about the cfe-commits mailing list