mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-15 05:20:06 +08:00
Limit access end-of-struct warning a bit
Only warn if the struct has a non-zero size. You can't create objects of zero-sized structs, but they can be used inside sizeof (e.g. "sizeof (struct {int :0;})". The warning would always trigger for these, but as no objects can be created no accesses can ever happen.
This commit is contained in:
parent
7cd1ae7710
commit
31e5ad789a
2
tccgen.c
2
tccgen.c
@ -3471,7 +3471,7 @@ static void struct_layout(CType *type, AttributeDef *ad)
|
||||
type->ref->c = (c + (pcc ? (bit_pos + 7) >> 3 : 0)
|
||||
+ maxalign - 1) & -maxalign;
|
||||
type->ref->r = maxalign;
|
||||
if (offset + size > type->ref->c)
|
||||
if (offset + size > type->ref->c && type->ref->c)
|
||||
tcc_warning("will touch memory past end of the struct (internal limitation)");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user