The following code compiles and runs, but shouldn't, because the size of structure a overflows size_t type. Overflowed size is checked for arrays, for global and local variables, but not for structures.
struct a { char x[0x7fffffff]; char b[0x7fffffff]; char c[3]; }; main() { struct a *b = malloc(sizeof(struct a)); return sizeof (struct a); } -- Summary: Gcc doesn't check overflowed size of structure Product: gcc Version: 3.4.2 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mikulas at artax dot karlin dot mff dot cuni dot cz CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18063