[cfe-dev] A problem about builtin-type creation

Reid Kleckner rnk at google.com
Tue Aug 5 10:48:48 PDT 2014


It is asserting that the Type pointer is not 16 byte aligned. Types are
generally constructed and uniqued in an ASTContext, which guarantees this
alignment.  See this at the top of Type.h:
  enum {
    TypeAlignmentInBits = 4,
    TypeAlignment = 1 << TypeAlignmentInBits
  };

Presumably you are building 32-bit code, where the system malloc returns 8
byte aligned chunks.


On Tue, Aug 5, 2014 at 10:11 AM, peterlee <peterlee at cs.utah.edu> wrote:

> Dear All,
>
> I am using Clang/LLVM-3.3, at present, I am fixing an error about creating
> a builtin type, the code is supposed to
> generate a "boolean" type with the following code:
>
> clang::Type* bool_type = new clang::BuiltinType(clang::BuiltinType::Bool);
> params.push_back(klimt::NamedDecl(clang::QualType(bool_type, 0), pname));
>
> I always encountered the error:
>
> /home/xxx/vendor/llvm-3.3/build32/Release+Asserts/../../include/llvm/ADT/PointerIntPair.h:100:
> void llvm::PointerIntPair<PointerTy, IntBits, IntType,
> PtrTraits>::initWithPointer(PointerTy) [with PointerTy = void*; unsigned
> int IntBits = 1u; IntType = bool; PtrTraits = llvm::PointerUnionUIntTraits<const
> clang::Type*, const clang::ExtQuals*>]: Assertion `(PtrWord & ((1 <<
> PtrTraits::NumLowBitsAvailable)-1)) == 0 && "Pointer is not sufficiently
> aligned"' failed
>
> The assertion fails at the BuiltinType creation.
>
> Any thoughts about how to fix this error is highly appreciated!
>
> Thanks
> Peng
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140805/f12ea0a4/attachment.html>


More information about the cfe-dev mailing list