Hi all, I ran across this in some of my kernel code, and isolated it into a few test cases, below. sparse should not report errors on this file, but does regardless, somehow the structs appear larger to it than they are. johannes This is suitable for dropping into the validation directory: --- begin file --- struct A { unsigned char a, b, c, d; } __attribute__((packed)); struct B { struct A A; unsigned char e, f; unsigned short g; unsigned char h; } __attribute__((packed)); struct C { unsigned char a, b, c, d; unsigned char e, f; unsigned short g; unsigned char h; } __attribute__((packed)); struct D { unsigned char h; } __attribute__((packed)); struct E { unsigned short g; unsigned char h; } __attribute__((packed)); #define BUILD_BUG_ON(expr) ((void)(sizeof(struct { int:-!!(expr); }))) static inline void foo(void) { BUILD_BUG_ON(sizeof(struct A) != 4); BUILD_BUG_ON(sizeof(struct B) != 9); BUILD_BUG_ON(sizeof(struct C) != 9); BUILD_BUG_ON(sizeof(struct D) != 1); BUILD_BUG_ON(sizeof(struct E) != 3); } /* * check-name: packed struct sizeof */ -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html