[cfe-dev] Static Assertions inside VarDecl constructor

Amila Jayasekara thejaka.amila at gmail.com
Tue Jun 2 09:24:40 PDT 2015


Inside VarDecl constructor (Decl.cpp L1721 in Clang 3.6) there are 2 static
assertions as follows;

VarDecl::VarDecl(Kind DK, ASTContext &C, DeclContext *DC,...) {

  static_assert(sizeof(VarDeclBitfields) <= sizeof(unsigned),
          "VarDeclBitfields too large!");
  static_assert(sizeof(ParmVarDeclBitfields) <= sizeof(unsigned),
          "ParmVarDeclBitfields too large!");

I am trying to add an another field to VarDeclBitfields and it triggers
second static assertion in above code.

Could you please explain why sizeof VarDeclBitfields and
ParmVarDeclBitfields must be less than sizeof(unsigned) and also what are
repercussions if I remove above assertions ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150602/e75ebbcc/attachment.html>

More information about the cfe-dev mailing list