[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 22:57:59 PST 2009


On Fri, 2009-01-23 at 11:28 +0530, sanjiv gupta wrote:
> 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.
> 
> 
I forgot to mention that int is i16 for PIC16.

- Sanjiv

> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list